Serials: Test method to identify holdings that lead to summarization bugs
authorLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Mon, 6 May 2013 18:13:13 +0000 (14:13 -0400)
committerDan Wells <dbw2@calvin.edu>
Mon, 13 May 2013 19:33:56 +0000 (15:33 -0400)
This adds a simple test method that allows testing of problem holdings.
See the next commit.

Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Signed-off-by: Remington Steed <rjs7@calvin.edu>
Signed-off-by: Dan Wells <dbw2@calvin.edu>
Open-ILS/src/perlmods/lib/OpenILS/Application/Serial.pm

index 377069d..19b14aa 100644 (file)
@@ -3643,4 +3643,35 @@ sub clone_subscription {
     return $result;
 }
 
+__PACKAGE__->register_method(
+    "method" => "summary_test",
+    "api_name" => "open-ils.serial.summary_test",
+    "stream" => 1,
+    "api_level" => 1,
+    "argc" => 3
+);
+
+# This crummy little test method allows quicker reproduction of certain
+# failures (e.g. at item receive time) of the holdings summarization code.
+# Pass it an authtoken, an array of issuance IDs, and a single sdist ID
+sub summary_test {
+    my ($self, $conn, $authtoken, $iss_id_list, $sdist_id) = @_;
+
+    my $e = new_editor(authtoken => $authtoken, xact => 1);
+    return $e->die_event unless $e->checkauth;
+    return $e->die_event unless $e->allowed("RECEIVE_SERIAL");
+
+    my @issuances;
+    foreach my $id (@$iss_id_list) {
+        my $iss = $e->retrieve_serial_issuance($id) or return $e->die_event;
+        push @issuances, $iss;
+    }
+
+    my $dist = $e->retrieve_serial_distribution($sdist_id) or return $e->die_event;
+
+    $conn->respond(_summarize_contents($e, \@issuances, $dist));
+    $e->rollback;
+    return;
+}
+
 1;