1
0
Fork 0
mirror of synced 2024-06-02 10:54:44 +12:00

Use correct key in metrics array

This commit is contained in:
kodumbeats 2021-10-27 18:17:51 -04:00
parent 79b1fceaf3
commit 6e46e2fb0f
5 changed files with 8 additions and 7 deletions

View file

@ -349,7 +349,7 @@ App::get('/v1/database/usage')
};
$stats[$metric][] = [
'value' => 0,
'date' => $stats[$metric][$last]['time'] - $diff, // time of last metric minus period
'date' => ($stats[$metric][$last]['date'] ?? \time()) - $diff, // time of last metric minus period
];
$backfill--;
}
@ -461,7 +461,7 @@ App::get('/v1/database/:collectionId/usage')
};
$stats[$metric][] = [
'value' => 0,
'date' => $stats[$metric][$last]['time'] - $diff, // time of last metric minus period
'date' => ($stats[$metric][$last]['date'] ?? \time()) - $diff, // time of last metric minus period
];
$backfill--;
}

View file

@ -231,7 +231,7 @@ App::get('/v1/functions/:functionId/usage')
};
$stats[$metric][] = [
'value' => 0,
'date' => $stats[$metric][$last]['time'] - $diff, // time of last metric minus period
'date' => ($stats[$metric][$last]['date'] ?? \time()) - $diff, // time of last metric minus period
];
$backfill--;
}

View file

@ -316,7 +316,7 @@ App::get('/v1/projects/:projectId/usage')
};
$stats[$metric][] = [
'value' => 0,
'date' => $stats[$metric][$last]['time'] - $diff, // time of last metric minus period
'date' => ($stats[$metric][$last]['date'] ?? \time()) - $diff, // time of last metric minus period
];
$backfill--;
}

View file

@ -724,7 +724,7 @@ App::get('/v1/storage/usage')
};
$stats[$metric][] = [
'value' => 0,
'date' => $stats[$metric][$last]['time'] - $diff, // time of last metric minus period
'date' => ($stats[$metric][$last]['date'] ?? \time()) - $diff, // time of last metric minus period
];
$backfill--;
}
@ -821,7 +821,7 @@ App::get('/v1/storage/:bucketId/usage')
};
$stats[$metric][] = [
'value' => 0,
'date' => $stats[$metric][$last]['time'] - $diff, // time of last metric minus period
'date' => ($stats[$metric][$last]['date'] ?? \time()) - $diff, // time of last metric minus period
];
$backfill--;
}

View file

@ -833,6 +833,7 @@ App::get('/v1/users/usage')
// backfill metrics with empty values for graphs
$backfill = $limit - \count($requestDocs);
while ($backfill > 0) {
$last = $limit - $backfill - 1; // array index of last added metric
$diff = match($period) { // convert period to seconds for unix timestamp math
'30m' => 1800,
@ -840,7 +841,7 @@ App::get('/v1/users/usage')
};
$stats[$metric][] = [
'value' => 0,
'date' => $stats[$metric][$last]['time'] - $diff, // time of last metric minus period
'date' => ($stats[$metric][$last]['date'] ?? \time()) - $diff, // time of last metric minus period
];
$backfill--;
}