Skip to content

Commit

Permalink
Print msgs odsm-filecache (#113)
Browse files Browse the repository at this point in the history
* Fixed calls to watchdog.

* Print status messages every 100 items processed.
  • Loading branch information
dharizza authored and janette committed Jun 4, 2019
1 parent d721837 commit 39cce9e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
8 changes: 4 additions & 4 deletions open_data_schema_map.file_cache.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand Down
9 changes: 9 additions & 0 deletions open_data_schema_map.module
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 39cce9e

Please sign in to comment.