From 379ce3abceb3e026b1e6267b063f3a6a9247970a Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Wed, 13 Jan 2021 12:10:43 +0545 Subject: [PATCH] refactoring with suggested updates --- app/controllers/api/functions.php | 5 ++--- app/controllers/api/projects.php | 3 +-- app/controllers/web/console.php | 3 ++- app/workers/functions.php | 4 ++-- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index 27dd75931..bad97b397 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -156,9 +156,8 @@ App::get('/v1/functions/:functionId/usage') if (empty($function->getId()) || Database::SYSTEM_COLLECTION_FUNCTIONS != $function->getCollection()) { throw new Exception('Function not found', 404); } - //check if stats is disabled - $appUsageStatsEnabled = App::getEnv('_APP_USAGE_STATS', 'enabled') == 'enabled'; - if($appUsageStatsEnabled) { + + if($App::getEnv('_APP_USAGE_STATS', 'enabled') == 'enabled') { $period = [ '24h' => [ 'start' => DateTime::createFromFormat('U', \strtotime('-24 hours')), diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index 1b6612742..1d8e18d00 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -176,8 +176,7 @@ App::get('/v1/projects/:projectId/usage') throw new Exception('Project not found', 404); } - $appUsageStatsEnabled = App::getEnv('_APP_USAGE_STATS', 'enabled') == 'enabled'; - if($appUsageStatsEnabled) { + if($App::getEnv('_APP_USAGE_STATS', 'enabled') == 'enabled') { $period = [ '24h' => [ diff --git a/app/controllers/web/console.php b/app/controllers/web/console.php index dadda3ec1..b8fc5a621 100644 --- a/app/controllers/web/console.php +++ b/app/controllers/web/console.php @@ -122,7 +122,8 @@ App::get('/console/home') /** @var Utopia\View $layout */ $page = new View(__DIR__.'/../../views/console/home/index.phtml'); - $page->setParam('usageStatsEnabled',App::getEnv('_APP_USAGE_STATS','enabled') == 'enabled'); + $page + ->setParam('usageStatsEnabled',App::getEnv('_APP_USAGE_STATS','enabled') == 'enabled'); $layout ->setParam('title', APP_NAME.' - Console') ->setParam('body', $page); diff --git a/app/workers/functions.php b/app/workers/functions.php index 51a18865e..bb74bb0e6 100644 --- a/app/workers/functions.php +++ b/app/workers/functions.php @@ -470,8 +470,8 @@ class FunctionsV1 ->setParam('networkRequestSize', 0) ->setParam('networkResponseSize', 0) ; - $appUsageStatsEnabled = App::getEnv('_APP_USAGE_STATS', 'enabled') == 'enabled'; - if($appUsageStatsEnabled) { + + if($App::getEnv('_APP_USAGE_STATS', 'enabled') == 'enabled') { $usage->trigger(); }