From 12e8af8bf4209fb8e99382294b3badf97ba91c79 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Thu, 20 Jul 2017 16:17:12 -0400 Subject: [PATCH] LP#1705731: background batch MARC edits now report status less verbosely Rather than repeatedly inserting and fetching potentially very large arrays of per-record status statements from the anon cache, batch MARC edits that are run in the background now report counts. This patch changes how open-ils.cat.container.template_overlay.background populates the anonymous cache; note that streaming status updates if calling open-ils.cat.container.template_overlay instead are *not* changed. To test ------- [1] Set up a MARC Batch Edit run using a reasonably large bucket as a source records. [2] Verify that progress is reported correctly during the run. Signed-off-by: Galen Charlton Signed-off-by: Bill Erickson --- .../perlmods/lib/OpenILS/Application/Cat.pm | 56 ++++++++++++++----- .../lib/OpenILS/WWW/TemplateBatchBibUpdate.pm | 19 ++----- 2 files changed, 49 insertions(+), 26 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Cat.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Cat.pm index 0800b889cd..e083c3b7ac 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Cat.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Cat.pm @@ -263,11 +263,11 @@ sub template_overlay_container { $template = $e->retrieve_biblio_record_entry( $titem->target_biblio_record_entry )->marc; } - my $responses = []; - my $some_failed = 0; + my $num_failed = 0; + my $num_succeeded = 0; $conn->respond_complete( - $actor->request('open-ils.actor.anon_cache.set_value', $auth, res_list => $responses)->gather(1) + $actor->request('open-ils.actor.anon_cache.set_value', $auth, batch_edit_progress => {})->gather(1) ) if ($actor); for my $item ( @$items ) { @@ -281,11 +281,20 @@ sub template_overlay_container { )->[0]->{'vandelay.template_overlay_bib_record'}; } - $some_failed++ if ($success eq 'f'); + if ($success eq 'f') { + $num_failed++; + } else { + $num_succeeded++; + } if ($actor) { - push @$responses, { record => $rec->id, success => $success }; - $actor->request('open-ils.actor.anon_cache.set_value', $auth, res_list => $responses); + $actor->request( + 'open-ils.actor.anon_cache.set_value', $auth, + batch_edit_progress => { + succeeded => $num_succeeded, + failed => $num_failed + }, + ); } else { $conn->respond({ record => $rec->id, success => $success }); } @@ -294,8 +303,15 @@ sub template_overlay_container { unless ($e->delete_container_biblio_record_entry_bucket_item($item)) { $e->rollback; if ($actor) { - push @$responses, { complete => 1, success => 'f' }; - $actor->request('open-ils.actor.anon_cache.set_value', $auth, res_list => $responses); + $actor->request( + 'open-ils.actor.anon_cache.set_value', $auth, + batch_edit_progress => { + complete => 1, + success => 'f', + succeeded => $num_succeeded, + failed => $num_failed, + } + ); return undef; } else { return { complete => 1, success => 'f' }; @@ -304,21 +320,35 @@ sub template_overlay_container { } } - if ($titem && !$some_failed) { + if ($titem && !$num_failed) { return $e->die_event unless ($e->delete_container_biblio_record_entry_bucket_item($titem)); } if ($e->commit) { if ($actor) { - push @$responses, { complete => 1, success => 't' }; - $actor->request('open-ils.actor.anon_cache.set_value', $auth, res_list => $responses); + $actor->request( + 'open-ils.actor.anon_cache.set_value', $auth, + batch_edit_progress => { + complete => 1, + success => 't', + succeeded => $num_succeeded, + failed => $num_failed, + } + ); } else { return { complete => 1, success => 't' }; } } else { if ($actor) { - push @$responses, { complete => 1, success => 'f' }; - $actor->request('open-ils.actor.anon_cache.set_value', $auth, res_list => $responses); + $actor->request( + 'open-ils.actor.anon_cache.set_value', $auth, + batch_edit_progress => { + complete => 1, + success => 'f', + succeeded => $num_succeeded, + failed => $num_failed, + } + ); } else { return { complete => 1, success => 'f' }; } diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/TemplateBatchBibUpdate.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/TemplateBatchBibUpdate.pm index 6d75965f16..fa4fc5d2c5 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/TemplateBatchBibUpdate.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/TemplateBatchBibUpdate.pm @@ -257,28 +257,21 @@ sub show_processing_template { fieldmapper.standardRequest( ['open-ils.actor','open-ils.actor.anon_cache.get_value'], { async : false, - params: [ u.authtoken, 'res_list' ], + params: [ u.authtoken, 'batch_edit_progress' ], onerror : function (r) { progress_dialog.hide(); }, onresponse : function (r) { var counter = { success : 0, fail : 0, total : 0 }; - dojo.forEach( openils.Util.readResponse(r), function(x) { + if (x = openils.Util.readResponse(r)) { + counter.success = x.succeeded; + counter.fail = x.failed; + counter.total = counter.success + counter.fail; if (x.complete) { clearInterval(interval); progress_dialog.hide(); if (x.success == 't') dojo.byId('complete_msg').innerHTML = 'Overlay completed successfully'; else dojo.byId('complete_msg').innerHTML = 'Overlay did not complet successfully'; - } else { - counter.total++; - switch (x.success) { - case 't': - counter.success++; - break; - default: - counter.fail++; - break; - } } - }); + }; // update the progress dialog progress_dialog.update({progress:counter.total}); -- 2.43.2