From daa68601684d8e783be2f06d6d9cbc09f65edc47 Mon Sep 17 00:00:00 2001 From: Jason Boyer Date: Mon, 19 Apr 2021 09:37:27 -0400 Subject: [PATCH] LP1925028: Make Hold/Copy Ratio Reports Consistent, Add a By Home Library Version Use ahcm for all hold/copy ratio reporting sources so the counts are more consistent, ignore metarecord hold copies (by default) and the copies from frozen or captured holds. Also a Hold/Copy Ratio per Bib and Home Library source is added. Sponsored-by: Westchester Library System Signed-off-by: Jason Boyer Signed-off-by: Rogan Hamby Signed-off-by: Chris Sharp --- Open-ILS/examples/fm_IDL.xml | 266 ++++++++++++++++++++++++++++++++----------- 1 file changed, 202 insertions(+), 64 deletions(-) diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml index 227619a60f..e03ebbbf61 100644 --- a/Open-ILS/examples/fm_IDL.xml +++ b/Open-ILS/examples/fm_IDL.xml @@ -12440,52 +12440,37 @@ SELECT usr, @@ -12509,7 +12494,7 @@ SELECT usr, CASE WHEN copy_count_at_pickup_library = 0 THEN 'Infinity'::FLOAT ELSE holds_at_pickup_library::FLOAT/copy_count_at_pickup_library END AS pickup_library_ratio, CASE WHEN copy_count_everywhere = 0 THEN 'Infinity'::FLOAT ELSE holds_everywhere::FLOAT/copy_count_everywhere END AS everywhere_ratio FROM - (SELECT bib_record as id, pickup_lib, count(DISTINCT ahr.id) AS holds_at_pickup_library, COALESCE(count(DISTINCT ac.id),0) as copy_count_at_pickup_library + (SELECT bib_record as id, pickup_lib, count(DISTINCT ahr.id) AS holds_at_pickup_library FROM action.hold_request ahr JOIN reporter.hold_request_record rhrr USING (id) @@ -12521,16 +12506,48 @@ SELECT usr, GROUP BY bib_record, pickup_lib )x JOIN - (SELECT bib_record as id, count(DISTINCT ahr.id) AS holds_everywhere, COALESCE(count(DISTINCT target_copy),0) as copy_count_everywhere + (SELECT bib_record as id, pickup_lib, COALESCE(count(DISTINCT ac.id),0) as copy_count_at_pickup_library FROM action.hold_request ahr JOIN reporter.hold_request_record rhrr USING (id) LEFT JOIN action.hold_copy_map ahcm ON (ahr.id = ahcm.hold) + LEFT JOIN asset.copy ac ON (ahcm.target_copy = ac.id AND ahr.pickup_lib = ac.circ_lib) WHERE ahr.cancel_time IS NULL AND ahr.fulfillment_time IS NULL - GROUP BY bib_record + AND ahr.capture_time IS NULL + AND ahr.frozen IS FALSE + -- Comment out the next line to count copies included from other bibs by metarecord holds + AND ahr.hold_type != 'M' + GROUP BY bib_record, pickup_lib )y + USING(id,pickup_lib) + JOIN + (SELECT bib_record as id, count(DISTINCT ahr.id) AS holds_everywhere + FROM + action.hold_request ahr + JOIN reporter.hold_request_record rhrr USING (id) + WHERE + ahr.cancel_time IS NULL + AND ahr.fulfillment_time IS NULL + GROUP BY bib_record + )z + USING (id) + JOIN + (SELECT bib_record as id, COALESCE(count(DISTINCT target_copy),0) as copy_count_everywhere + FROM + action.hold_request ahr + JOIN reporter.hold_request_record rhrr USING (id) + LEFT JOIN action.hold_copy_map ahcm ON (ahr.id = ahcm.hold) + WHERE + ahr.cancel_time IS NULL + AND ahr.fulfillment_time IS NULL + AND ahr.capture_time IS NULL + AND ahr.frozen IS FALSE + -- Comment out the next line to count copies included from other bibs by metarecord holds + AND ahr.hold_type != 'M' + GROUP BY bib_record + )u USING (id) ]]> @@ -12554,40 +12571,161 @@ SELECT usr, - + + + + + + + + + + + + + + + + + + + + + + + + -- 2.11.0