From: blake Date: Tue, 17 May 2016 21:27:00 +0000 (-0500) Subject: LP1582354 report able to show bibs where the last copy was deleted cancels X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=0325d0a5fcee2c6747064bdedee5d4c3462ea3f0;p=evergreen%2Fjoelewis.git LP1582354 report able to show bibs where the last copy was deleted cancels Created a view for ease of reporting. This source table allows you to construct a clever aggregate report template which will report bibliographic ID's where a library or a group of libraries no longer have a copy attached but had* a copy attached. This is especially useful when a holdings sync is required with an external vendor. Signed-off-by: blake Signed-off-by: Chris Sharp Signed-off-by: Jason Etheridge --- diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml index e0d75840fd..515f766f11 100644 --- a/Open-ILS/examples/fm_IDL.xml +++ b/Open-ILS/examples/fm_IDL.xml @@ -9491,6 +9491,26 @@ SELECT usr, + + + + + + + + + + + + + + + + + + + + diff --git a/Open-ILS/src/sql/Pg/extend-reporter.sql b/Open-ILS/src/sql/Pg/extend-reporter.sql index 852b537e4b..ca94530dad 100644 --- a/Open-ILS/src/sql/Pg/extend-reporter.sql +++ b/Open-ILS/src/sql/Pg/extend-reporter.sql @@ -54,6 +54,26 @@ CREATE OR REPLACE VIEW extend_reporter.global_bibs_by_holding_update AS AND b.id > 0 GROUP BY b.id)x ORDER BY id, holding_update; - -COMMIT; +CREATE OR REPLACE VIEW extend_reporter.copy_count_per_org AS + SELECT acn.record AS bibid, + ac.circ_lib, + max(ac.edit_date) AS last_edit_time, + min(ac.deleted::integer) AS has_only_deleted_copies, + count( + CASE + WHEN ac.deleted THEN ac.id + ELSE NULL::bigint + END) AS deleted_count, + count( + CASE + WHEN NOT ac.deleted THEN ac.id + ELSE NULL::bigint + END) AS visible_count, + count(*) AS total_count + FROM asset.call_number acn, + asset.copy ac + WHERE ac.call_number = acn.id + GROUP BY acn.record, ac.circ_lib; + +COMMIT; diff --git a/Open-ILS/src/sql/Pg/t/lp1582354_report_able_to_show_bibs_where_the_last_copy_was_deleted_cancels.pg b/Open-ILS/src/sql/Pg/t/lp1582354_report_able_to_show_bibs_where_the_last_copy_was_deleted_cancels.pg new file mode 100644 index 0000000000..b3f0a394c4 --- /dev/null +++ b/Open-ILS/src/sql/Pg/t/lp1582354_report_able_to_show_bibs_where_the_last_copy_was_deleted_cancels.pg @@ -0,0 +1,27 @@ +\set ECHO +\set QUIET 1 +-- Turn off echo and keep things quiet. + +-- Format the output for nice TAP. +\pset format unaligned +\pset tuples_only true +\pset pager + +-- Revert all changes on failure. +\set ON_ERROR_ROLLBACK 1 +\set ON_ERROR_STOP true +\set QUIET 1 + +-- Load the TAP functions. +BEGIN; + +-- Plan the tests. +SELECT plan(1); + +-- Run the tests. +-- Check for Lost and Paid copy status. +SELECT has_view( 'extend_reporter', 'copy_count_per_org', 'VIEW extend_reporter.copy_count_per_org EXISTS' ); + +-- Finish the tests and clean up. +SELECT * FROM finish(); +ROLLBACK; diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.LP1582354_report_able_to_show_bibs_where_the_last_copy_was_deleted_cancels.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.LP1582354_report_able_to_show_bibs_where_the_last_copy_was_deleted_cancels.sql new file mode 100644 index 0000000000..9b34294758 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.LP1582354_report_able_to_show_bibs_where_the_last_copy_was_deleted_cancels.sql @@ -0,0 +1,30 @@ +BEGIN; + +SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version); + +DROP VIEW IF EXISTS extend_reporter.copy_count_per_org; + + +CREATE OR REPLACE VIEW extend_reporter.copy_count_per_org AS + SELECT acn.record AS bibid, + ac.circ_lib, + max(ac.edit_date) AS last_edit_time, + min(ac.deleted::integer) AS has_only_deleted_copies, + count( + CASE + WHEN ac.deleted THEN ac.id + ELSE NULL::bigint + END) AS deleted_count, + count( + CASE + WHEN NOT ac.deleted THEN ac.id + ELSE NULL::bigint + END) AS visible_count, + count(*) AS total_count + FROM asset.call_number acn, + asset.copy ac + WHERE ac.call_number = acn.id + GROUP BY acn.record, ac.circ_lib; + + +COMMIT; diff --git a/docs/lp1582354_report_able_to_show_bibs_where_the_last_copy_was_deleted_cancels.adoc b/docs/lp1582354_report_able_to_show_bibs_where_the_last_copy_was_deleted_cancels.adoc new file mode 100644 index 0000000000..fdab109e8f --- /dev/null +++ b/docs/lp1582354_report_able_to_show_bibs_where_the_last_copy_was_deleted_cancels.adoc @@ -0,0 +1,25 @@ +New report source table allowing report of "last" deleted copy +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This source table allows you to construct a clever aggregate report template +which will report bibliographic ID's where a library or a group of libraries +no longer have a copy attached but had* a copy attached. This is especially +useful when a holdings sync is required with an external vendor. + + +Instructions for creating the report template: + * Create a new report template using the "Library Holdings Count with Deleted" as the source + * Add "Has Only Deleted Copies 0/1" (Min) to the Aggregate Filters -> Change Value to "1" + * Add "Last Edit Date" (Max) to Aggregate Filters -> Change Operator to "Between" + * Add Circulation Library -> "Organizational Unit ID" Raw Data to Base Filters -> Change Operator to "In list" + * Add "Bib ID" to Displayed Fields + * Add "Last Edit Date" to Displayed Fields and Change Transform to Max + * Add "Has Only Deleted Copies 0/1" to Displayed Fields and Change Transform to Min + * Add "Total copies attached" to Displayed Fields and Change Transform to Sum + + +This template will only output bibliographic ID's where all of the copies for the specified branch(es) +are deleted. Furthermore, it will only output bibs whose copies were edited (deleted) during the +specified date range. Unfortunatly the user will have to manually type the date range without the date +picker. This view will also allow you to answer questions like "Show me bibs where I have one visible +copy and more than two deleted copies."