From dfa35e0a0b86dac40b45cfded7a4c5a0ffc11179 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Fri, 21 Oct 2022 05:45:25 +0000 Subject: [PATCH] fix periods on usage endpoints --- app/controllers/api/functions.php | 12 ++++++------ app/controllers/api/projects.php | 6 +++--- app/controllers/api/storage.php | 10 +++++----- app/controllers/api/users.php | 6 +++--- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index d3a26b414..a8df29582 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -237,8 +237,8 @@ App::get('/v1/functions/:functionId/usage') if (App::getEnv('_APP_USAGE_STATS', 'enabled') == 'enabled') { $periods = [ '24h' => [ - 'period' => '30m', - 'limit' => 48, + 'period' => '1h', + 'limit' => 24, ], '7d' => [ 'period' => '1d', @@ -292,7 +292,7 @@ App::get('/v1/functions/:functionId/usage') 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, + '1h' => 3600, '1d' => 86400, }; $stats[$metric][] = [ @@ -340,8 +340,8 @@ App::get('/v1/functions/usage') if (App::getEnv('_APP_USAGE_STATS', 'enabled') == 'enabled') { $periods = [ '24h' => [ - 'period' => '30m', - 'limit' => 48, + 'period' => '1h', + 'limit' => 24, ], '7d' => [ 'period' => '1d', @@ -395,7 +395,7 @@ App::get('/v1/functions/usage') 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, + '1h' => 3600, '1d' => 86400, }; $stats[$metric][] = [ diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index bfea863d2..1ed6bd62d 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -269,8 +269,8 @@ App::get('/v1/projects/:projectId/usage') if (App::getEnv('_APP_USAGE_STATS', 'enabled') == 'enabled') { $periods = [ '24h' => [ - 'period' => '30m', - 'limit' => 48, + 'period' => '1h', + 'limit' => 24, ], '7d' => [ 'period' => '1d', @@ -325,7 +325,7 @@ App::get('/v1/projects/:projectId/usage') 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, + '1h' => 3600, '1d' => 86400, }; $stats[$metric][] = [ diff --git a/app/controllers/api/storage.php b/app/controllers/api/storage.php index 781825704..176d32081 100644 --- a/app/controllers/api/storage.php +++ b/app/controllers/api/storage.php @@ -1454,8 +1454,8 @@ App::get('/v1/storage/usage') if (App::getEnv('_APP_USAGE_STATS', 'enabled') === 'enabled') { $periods = [ '24h' => [ - 'period' => '30m', - 'limit' => 48, + 'period' => '1h', + 'limit' => 24, ], '7d' => [ 'period' => '1d', @@ -1513,7 +1513,7 @@ App::get('/v1/storage/usage') 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, + '1h' => 3600, '1d' => 86400, }; $stats[$metric][] = [ @@ -1572,7 +1572,7 @@ App::get('/v1/storage/:bucketId/usage') $periods = [ '24h' => [ 'period' => '1h', - 'limit' => 48, + 'limit' => 24, ], '7d' => [ 'period' => '1d', @@ -1624,7 +1624,7 @@ App::get('/v1/storage/:bucketId/usage') 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, + '1h' => 3600, '1d' => 86400, }; $stats[$metric][] = [ diff --git a/app/controllers/api/users.php b/app/controllers/api/users.php index c95105b77..6211176a0 100644 --- a/app/controllers/api/users.php +++ b/app/controllers/api/users.php @@ -1116,8 +1116,8 @@ App::get('/v1/users/usage') if (App::getEnv('_APP_USAGE_STATS', 'enabled') == 'enabled') { $periods = [ '24h' => [ - 'period' => '30m', - 'limit' => 48, + 'period' => '1h', + 'limit' => 24, ], '7d' => [ 'period' => '1d', @@ -1171,7 +1171,7 @@ App::get('/v1/users/usage') 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, + '1h' => 3600, '1d' => 86400, }; $stats[$metric][] = [