From 877fcbe1400dadc17a8f5311f8539ac60135d9cb Mon Sep 17 00:00:00 2001 From: Kyle McGuffin Date: Wed, 14 Feb 2024 10:02:40 -0500 Subject: [PATCH 1/5] Move all getData calls to top of file --- sop/sop_data_activity_log.php | 97 ++++++++++++++++++++++++++--------- 1 file changed, 72 insertions(+), 25 deletions(-) diff --git a/sop/sop_data_activity_log.php b/sop/sop_data_activity_log.php index f890f37..b17c26b 100644 --- a/sop/sop_data_activity_log.php +++ b/sop/sop_data_activity_log.php @@ -3,16 +3,56 @@ $record = htmlentities($_REQUEST['record'],ENT_QUOTES); +### Fetch People and Region data for inclusion in upload/download details +$people = \REDCap::getData($pidsArray['PEOPLE'], 'json-array', null, array('firstname','lastname','person_region')); + +$peopleDetails = []; +foreach($people as $personDetails) { + $peopleDetails[$personDetails["record_id"]] = $personDetails; +} + +$regions = \REDCap::getData($pidsArray['REGIONS'], 'json-array', null); + +$regionDetails = []; +foreach($regions as $thisRegionDetails) { + $regionDetails[$thisRegionDetails["record_id"]] = $thisRegionDetails; +} + +## Sort into list by region_code +ArrayFunctions::array_sort_by_column($regions, 'region_code'); + +$regionList = []; +if (!empty($regions)) { + foreach ($regions as $region) { + $regionList[$region["record_id"]] = $region["region_code"]; + } +} + +## Pull ALL data from Data Upload $dataUpload_sevenDaysYoung = \REDCap::getData($pidsArray['DATAUPLOAD'], 'json-array', null); -ArrayFunctions::array_sort_by_column($dataUpload_sevenDaysYoung, 'responsecomplete_ts',SORT_DESC); +## Set up upload records array keyed by record_id +$uploadDetails = []; +foreach($dataUpload_sevenDaysYoung as $recordDetails) { + $uploadDetails[$recordDetails["record_id"]] = $recordDetails; +} + +## Pull ALL data from Data Download $dataDownload_sevenDaysYoung = \REDCap::getData($pidsArray['DATADOWNLOAD'], 'json-array', null); -ArrayFunctions::array_sort_by_column($dataDownload_sevenDaysYoung, 'responsecomplete_ts',SORT_DESC); + +$downloadDetails = []; +## Fetch the upload details for each download record +foreach($dataDownload_sevenDaysYoung as $recordDetails) { + $downloadDetails[$recordDetails["record_id"]] = $recordDetails; +} $all_data_recent_activity = array_merge($dataUpload_sevenDaysYoung, $dataDownload_sevenDaysYoung); +## Sort into list by responsecomplete_ts ArrayFunctions::array_sort_by_column($all_data_recent_activity, 'responsecomplete_ts',SORT_DESC); + +## Post page load data lookup details $datareq_id = ''; $datareq_title = ''; if(array_key_exists('record', $_REQUEST) && $record != ''){ @@ -167,16 +207,11 @@ function getQueryString() {