From 39cce9ee8c88e76995a81e5734aa71a1a7dc4e23 Mon Sep 17 00:00:00 2001 From: Dharizza Espinach B Date: Tue, 4 Jun 2019 13:31:37 -0600 Subject: [PATCH] Print msgs odsm-filecache (#113) * Fixed calls to watchdog. * Print status messages every 100 items processed. --- open_data_schema_map.file_cache.inc | 8 ++++---- open_data_schema_map.module | 9 +++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/open_data_schema_map.file_cache.inc b/open_data_schema_map.file_cache.inc index fb654c9..aa44fdc 100644 --- a/open_data_schema_map.file_cache.inc +++ b/open_data_schema_map.file_cache.inc @@ -82,19 +82,19 @@ function open_data_schema_map_file_cache_exits($api, $arguments = array()) { function open_data_schema_map_file_cache_endpoint($machine_name) { $api = open_data_schema_map_api_load($machine_name); if (isset($api)) { - watchdog('open_data_schema_map', 'api present and loaded', WATCHDOG_INFO); + watchdog('open_data_schema_map', 'api present and loaded', [], WATCHDOG_INFO); $filename = open_data_schema_map_file_cache_name_helper($api); // This will only work for data.json v1.1 right now. - watchdog('open_data_schema_map', 'Beginning processing for endpoint (this could take a while)', WATCHDOG_INFO); + watchdog('open_data_schema_map', 'Beginning processing for endpoint (this could take a while)', [], WATCHDOG_INFO); $render = open_data_schema_map_render_api($api); $result = $render['result']; // Load the correct output format, render results, and write to a file. if ($output_format = open_data_schema_map_output_format_load($api->outputformat)) { $response = $output_format['callback']($api, $result); - watchdog('open_data_schema_map', "Saving $filename", WATCHDOG_INFO); + watchdog('open_data_schema_map', "Saving $filename", [], WATCHDOG_INFO); file_save_data($response, $filename, FILE_EXISTS_REPLACE); - watchdog('open_data_schema_map', "$filename saved", WATCHDOG_INFO); + watchdog('open_data_schema_map', "$filename saved", [], WATCHDOG_INFO); } } } diff --git a/open_data_schema_map.module b/open_data_schema_map.module index ecec4ac..6d056cc 100644 --- a/open_data_schema_map.module +++ b/open_data_schema_map.module @@ -1035,11 +1035,20 @@ function open_data_schema_map_endpoint_args(&$map, $queries, $args = array()) { function open_data_schema_map_endpoint_process_map($ids, $api) { $output = array(); if ($ids) { + $total = count($ids); + $count = 0; + $index = 0; foreach ($ids as $key => $id) { $result = array(); $entity = entity_load_single($api->type, $id); open_data_schema_map_endpoint_process_map_recursion($result, $api->mapping, $api->type, $entity); $output[] = $result; + $count++; + $index++; + if ($count == 100 || $index == $total) { + drush_log("Processed $index out of $total items", "ok"); + $count = 0; + } } } return $output;