From: Mike Rylander Date: Thu, 24 Mar 2016 20:07:32 +0000 (-0400) Subject: LP#1549505: Filter more copies where possible in hold and circ populations X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=9031c92e336ceecc2f552ba9d3ce652ec2f17c35;p=working%2FEvergreen.git LP#1549505: Filter more copies where possible in hold and circ populations Signed-off-by: Mike Rylander --- diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.statisitcal-ratings.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.statisitcal-ratings.sql index e690b8edb4..b18f002826 100644 --- a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.statisitcal-ratings.sql +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.statisitcal-ratings.sql @@ -634,10 +634,12 @@ BEGIN RETURN QUERY SELECT f.id AS bib, - COUNT(h.id)::NUMERIC AS holds + COUNT(DISTINCT h.id)::NUMERIC AS holds FROM action.hold_request h JOIN reporter.hold_request_record rhrr ON (rhrr.id = h.id) JOIN precalc_bib_list f ON (f.id = rhrr.bib_record) + JOIN precalc_copy_filter_bib_list cf ON (f.id = cf.id) + JOIN action.hold_copy_map m ON (m.target_copy = cf.copy AND m.hold = h.id) WHERE h.fulfillment_time IS NULL AND h.request_lib = ANY (badge.orgs) GROUP BY 1; @@ -689,6 +691,7 @@ BEGIN JOIN asset.copy cp ON (cp.id = c.target_copy) JOIN asset.call_number cn ON (cn.id = cp.call_number) JOIN precalc_bib_list f ON (f.id = cn.record) + JOIN precalc_copy_filter_bib_list cf ON (f.id = cf.id AND cp.id = cf.copy) WHERE c.xact_start >= NOW() - badge.horizon_age AND cn.owning_lib = ANY (badge.orgs) AND c.phone_renewal IS FALSE -- we don't count renewals @@ -724,6 +727,7 @@ BEGIN JOIN asset.copy cp ON (cp.id = c.target_copy) JOIN asset.call_number cn ON (cn.id = cp.call_number) JOIN precalc_bib_list f ON (f.id = cn.record) + JOIN precalc_copy_filter_bib_list cf ON (f.id = cf.id AND cp.id = cf.copy) WHERE c.checkin_time IS NULL AND cn.owning_lib = ANY (badge.orgs) GROUP BY 1; @@ -756,6 +760,7 @@ BEGIN FROM asset.copy cp JOIN asset.call_number cn ON (cn.id = cp.call_number) JOIN precalc_bib_list f ON (f.id = cn.record) + JOIN precalc_copy_filter_bib_list c ON (f.id = c.id AND cp.id = c.copy) WHERE cn.owning_lib = ANY (badge.orgs) ) x GROUP BY 1; @@ -785,7 +790,8 @@ BEGIN FROM asset.copy cp JOIN asset.call_number cn ON (cn.id = cp.call_number) JOIN precalc_bib_list f ON (f.id = cn.record) - LEFT JOIN action.hold_copy_map m ON (m.target_copy = cp.id) + JOIN precalc_copy_filter_bib_list c ON (f.id = c.id AND cp.id = c.copy) + JOIN action.hold_copy_map m ON (m.target_copy = cp.id) WHERE cn.owning_lib = ANY (badge.orgs) GROUP BY 1; END; @@ -816,7 +822,8 @@ BEGIN JOIN config.copy_status cs ON (cs.id = cp.status) JOIN asset.call_number cn ON (cn.id = cp.call_number) JOIN precalc_bib_list f ON (f.id = cn.record) - LEFT JOIN action.hold_copy_map m ON (m.target_copy = cp.id) + JOIN precalc_copy_filter_bib_list c ON (f.id = c.id AND cp.id = c.copy) + JOIN action.hold_copy_map m ON (m.target_copy = cp.id) WHERE cn.owning_lib = ANY (badge.orgs) AND cp.holdable IS TRUE AND cl.holdable IS TRUE @@ -914,6 +921,7 @@ BEGIN FROM asset.copy cp JOIN asset.call_number cn ON (cn.id = cp.call_number) JOIN precalc_bib_list f ON (f.id = cn.record) + JOIN precalc_copy_filter_bib_list c ON (f.id = c.id AND cp.id = c.copy) LEFT JOIN action.all_circulation circ ON ( circ.target_copy = cp.id AND stop_fines NOT IN (