diff --git a/services/nginx/app/objects/departments_o.php b/services/nginx/app/objects/departments_o.php index ca2f2dee..9dc3f979 100644 --- a/services/nginx/app/objects/departments_o.php +++ b/services/nginx/app/objects/departments_o.php @@ -462,7 +462,7 @@ class departments_o extends db { self::requireSelected(); // Ensure only one message is sent a week using redis cache - $cacheKey = "department_{$this->id}_weekly_statistics_sent"; + $cacheKey = "department_{$this->id}_weekly_statistics_sent_v2"; // Get time until next monday at 00:00:00 $nextMonday = strtotime('next monday'); $cacheDuration = $nextMonday - time(); diff --git a/services/nginx/app/routes/departmentsRoute.php b/services/nginx/app/routes/departmentsRoute.php index 9d5a0c3c..642c6b90 100644 --- a/services/nginx/app/routes/departmentsRoute.php +++ b/services/nginx/app/routes/departmentsRoute.php @@ -433,15 +433,14 @@ class departmentsRoute self::get('/departments/weekly-results', function () { // Require the user to be logged in global $response; - //self::requirePermission('view_department_weekly_results'); TODO: enable permission check once the feature is fully implemented and tested + self::requirePermission('view_department_weekly_results'); // Get the user object - //$user = (new authentication())->get_user(); - $user = true; + $user = (new authentication())->get_user(); // Check if the request was successful if ($user) { // Get the department results for the week $departments_o = new departments_o(); - $weeks = 5; + $weeks = 3; $results = []; for ($i = 0; $i < $weeks; $i++) { // Get the week number @@ -476,12 +475,12 @@ class departmentsRoute } } // Log the incident - //(new logs_o())->add('departments', 'global', 1, $user->id, 'VIEW_DEPARTMENT_WEEKLY_RESULTS', 'Successfully viewed department weekly results'); + (new logs_o())->add('departments', 'global', 1, $user->id, 'VIEW_DEPARTMENT_WEEKLY_RESULTS', 'Successfully viewed department weekly results'); // Return the results $response->success($results); } else { // Log the incident - //(new logs_o())->add('departments', 'global', 1, 0, 'VIEW_DEPARTMENT_WEEKLY_RESULTS', 'No user found, or invalid session'); + (new logs_o())->add('departments', 'global', 1, 0, 'VIEW_DEPARTMENT_WEEKLY_RESULTS', 'No user found, or invalid session'); // Return an error $response->error('Invalid session', 400); }