From 66d9ae3599483b12bec4ec087f130df4a8d6313c Mon Sep 17 00:00:00 2001 From: Anatoly Date: Tue, 22 Nov 2022 13:31:22 +0200 Subject: [PATCH 1/2] Fix stats generation for HC with no FBF groups [ci skip] --- server/hedley/modules/custom/hedley_stats/hedley_stats.module | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/server/hedley/modules/custom/hedley_stats/hedley_stats.module b/server/hedley/modules/custom/hedley_stats/hedley_stats.module index 8e0ea0f3e0..ec9223e403 100644 --- a/server/hedley/modules/custom/hedley_stats/hedley_stats.module +++ b/server/hedley/modules/custom/hedley_stats/hedley_stats.module @@ -335,9 +335,7 @@ function hedley_stats_calculate_stats_for_health_center($health_center_id) { // Get all clinics of type 'FBF' for the HC. $fbf_clinics = hedley_health_center_get_clinics_by_health_center($health_center_id, 'fbf'); // Calculate statistics that are provided for FBF clinics only. - if (!empty($fbf_clinics)) { - hedley_stats_get_session_attendance_stats_by_health_center($health_center_id, $fbf_clinics); - } + hedley_stats_get_session_attendance_stats_by_health_center($health_center_id, $fbf_clinics); $villages_with_residents = hedley_stats_get_villages_with_residents($health_center_id); From 0fb9eb2d247ce93bb22e4be21fd96bf0fb1495b1 Mon Sep 17 00:00:00 2001 From: Anatoly Date: Tue, 22 Nov 2022 13:33:24 +0200 Subject: [PATCH 2/2] Allow defining a list of HCs that will not generate stats --- .../restful/node/HedleyRestfulSync.class.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/server/hedley/modules/custom/hedley_restful/plugins/restful/node/HedleyRestfulSync.class.php b/server/hedley/modules/custom/hedley_restful/plugins/restful/node/HedleyRestfulSync.class.php index 91e51e7d52..a079227601 100644 --- a/server/hedley/modules/custom/hedley_restful/plugins/restful/node/HedleyRestfulSync.class.php +++ b/server/hedley/modules/custom/hedley_restful/plugins/restful/node/HedleyRestfulSync.class.php @@ -319,10 +319,17 @@ public function getForHealthCenterStatistics($uuid) { $cached_hash = hedley_stats_handle_cache(HEDLEY_STATS_CACHE_GET, HEDLEY_STATS_SYNC_STATS_CACHE, $health_center_id); if (empty($cached_hash)) { // There's no cached data for health center - trigger statistics - // calculation by adding an AQ item. - hedley_general_add_task_to_advanced_queue_by_id(HEDLEY_STATS_CALCULATE_STATS, $health_center_id, [ - 'health_center_nid' => $health_center_id, - ]); + // calculation, unless health center is member of exclusion list. + $excluded_health_centers = variable_get('hedley_statistics_excluded_health_centers', ''); + $excluded_health_centers = explode(',', $excluded_health_centers); + if (array_search($health_center_id, $excluded_health_centers) === FALSE) { + // This health center is not excluded - trigger statistics calculation + // by adding an AQ item. + hedley_general_add_task_to_advanced_queue_by_id(HEDLEY_STATS_CALCULATE_STATS, $health_center_id, [ + 'health_center_nid' => $health_center_id, + ]); + } + return $return; }