From: a. bellenir Date: Tue, 5 Jun 2018 19:56:24 +0000 (-0400) Subject: LP#1775216: inconsistent availability counts between staff client and opac X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=26620e50e69f6fc15e222633054f18e7eada68ec;p=working%2FEvergreen.git LP#1775216: inconsistent availability counts between staff client and opac update asset.staff_ou_record_copy_count to get an accurate available count. borrow asset.opac_ou_record_copy_count's logic for counting available copies so that statuses with is_available set to 't' in config.copy_status are used instead of using the hardcoded status id list (0,7,12) Signed-off-by: a. bellenir --- diff --git a/Open-ILS/src/sql/Pg/040.schema.asset.sql b/Open-ILS/src/sql/Pg/040.schema.asset.sql index 24dda3c41b..564df64cb3 100644 --- a/Open-ILS/src/sql/Pg/040.schema.asset.sql +++ b/Open-ILS/src/sql/Pg/040.schema.asset.sql @@ -625,13 +625,15 @@ BEGIN FOR ans IN SELECT u.id, t.depth FROM actor.org_unit_ancestors(org) AS u JOIN actor.org_unit_type t ON (u.ou_type = t.id) LOOP RETURN QUERY + WITH available_statuses AS (SELECT ARRAY_AGG(id) AS ids FROM config.copy_status WHERE is_available) SELECT ans.depth, ans.id, COUNT( cp.id ), - SUM( CASE WHEN cp.status IN (0,7,12) THEN 1 ELSE 0 END ), + SUM( (cp.status = ANY (available_statuses.ids))::INT ), SUM( CASE WHEN cl.opac_visible AND cp.opac_visible THEN 1 ELSE 0 END), trans FROM + available_statuses, actor.org_unit_descendants(ans.id) d JOIN asset.copy cp ON (cp.circ_lib = d.id AND NOT cp.deleted) JOIN asset.copy_location cl ON (cp.location = cl.id AND NOT cl.deleted)