Skip to content

Commit

Permalink
feat: fetch metric data for smaller periods
Browse files Browse the repository at this point in the history
  • Loading branch information
ilayda-cp committed Sep 26, 2024
1 parent edeb11d commit 4f41a98
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions static/js/publisher-pages/hooks/useActiveDeviceMetrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,14 @@ function useActiveDeviceMetrics({
const response = await fetch(
`/${snapId}/metrics/active-devices?active-devices=${type}&start=${startDate.toISOString().split("T")[0]}&end=${endDate.toISOString().split("T")[0]}`
);
console.log(response);
const data = await response.json();
setFetchedData({
activeDevices: {
buckets: data.active_devices.buckets,
name: data.active_devices.name,
series: data.active_devices.series,
},
});
} else {
// pagiante
const numberOfIterations =
Expand Down Expand Up @@ -135,7 +142,6 @@ function useActiveDeviceMetrics({

for (const result of results.reverse()) {
const data = await result.json();
console.log(data);

const activeDeviceBuckets = data.active_devices.buckets;

Expand Down Expand Up @@ -173,6 +179,8 @@ function useActiveDeviceMetrics({
values: value,
}));

console.log(resultArray);

setFetchedData({
activeDevices: {
buckets,
Expand All @@ -182,6 +190,7 @@ function useActiveDeviceMetrics({
});
}
};

useEffect(() => {
fetchData();
}, []);
Expand Down

0 comments on commit 4f41a98

Please sign in to comment.