From: Dan Scott Date: Sun, 18 Dec 2011 16:21:19 +0000 (-0500) Subject: unapi: avoid deleted call numbers, copies, and sunits X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=d3f53980df90c865de9cddfa2aa714ec3a5f5877;p=working%2FEvergreen.git unapi: avoid deleted call numbers, copies, and sunits The rewrite of unapi removed the filters for deleted call numbers that were added to master in LP# 893315 / commit hash 47a16f516d. Without this filter, it is possible to return pages of results that would show nothing in the TPAC because all of the call numbers were deleted. This commit reinstates the check for the deleted condition on call numbers and adds a check for the deleted condition on copies and serial units as well. The check could be made conditional by adding yet another parameter to the unapi api, but there appears to be no compelling reason to make the signature more complex for now. Signed-off-by: Dan Scott --- diff --git a/Open-ILS/src/sql/Pg/990.schema.unapi.sql b/Open-ILS/src/sql/Pg/990.schema.unapi.sql index decde34df7..42bfb8bbab 100644 --- a/Open-ILS/src/sql/Pg/990.schema.unapi.sql +++ b/Open-ILS/src/sql/Pg/990.schema.unapi.sql @@ -284,6 +284,8 @@ CREATE OR REPLACE FUNCTION unapi.holdings_xml (bid BIGINT, ouid INT, org TEXT, d JOIN actor.org_unit_descendants( $2 ) aoud ON (acp.circ_lib = aoud.id) INNER JOIN actor.org_unit aou ON (aou.id = acp.circ_lib) WHERE acn.record = $1 + AND acn.deleted IS FALSE + AND acp.deleted IS FALSE ORDER BY acp.circ_lib, acn.label_sortkey LIMIT ($6 -> 'acn')::INT OFFSET ($7 -> 'acn')::INT @@ -301,6 +303,8 @@ CREATE OR REPLACE FUNCTION unapi.holdings_xml (bid BIGINT, ouid INT, org TEXT, d JOIN actor.org_unit_descendants( $2, $4 ) aoud ON (acp.circ_lib = aoud.id) INNER JOIN actor.org_unit aou ON (aou.id = acp.circ_lib) WHERE acn.record = $1 + AND acn.deleted IS FALSE + AND acp.deleted IS FALSE ORDER BY acp.circ_lib, acn.label_sortkey LIMIT ($6 -> 'acn')::INT OFFSET ($7 -> 'acn')::INT @@ -660,6 +664,7 @@ CREATE OR REPLACE FUNCTION unapi.bmp ( obj_id BIGINT, format TEXT, ename TEXT, FROM asset.copy cp JOIN asset.copy_part_map cpm ON (cpm.target_copy = cp.id) WHERE cpm.part = $1 + AND cp.deleted IS FALSE ORDER BY COALESCE(cp.copy_number,0), cp.barcode LIMIT ($7 -> 'acp')::INT OFFSET ($8 -> 'acp')::INT @@ -750,6 +755,7 @@ CREATE OR REPLACE FUNCTION unapi.acp ( obj_id BIGINT, format TEXT, ename TEXT, ) FROM asset.copy cp WHERE id = $1 + AND cp.deleted IS FALSE GROUP BY id, status, location, circ_lib, call_number, create_date, edit_date, copy_number, circulate, deposit, ref, holdable, deleted, deposit_amount, price, barcode, circ_modifier, circ_as_type, opac_visible; $F$ LANGUAGE SQL; @@ -829,6 +835,7 @@ CREATE OR REPLACE FUNCTION unapi.sunit ( obj_id BIGINT, format TEXT, ename TEXT ) FROM serial.unit cp WHERE id = $1 + AND cp.deleted IS FALSE GROUP BY id, status, location, circ_lib, call_number, create_date, edit_date, copy_number, circulate, floating, mint_condition, deposit, ref, holdable, deleted, deposit_amount, price, barcode, circ_modifier, circ_as_type, opac_visible, status_changed_time, detailed_contents, sort_key, summary_contents, cost; $F$ LANGUAGE SQL; @@ -853,6 +860,7 @@ CREATE OR REPLACE FUNCTION unapi.acn ( obj_id BIGINT, format TEXT, ename TEXT, FROM asset.copy cp JOIN actor.org_unit_descendants( (SELECT id FROM actor.org_unit WHERE shortname = $5), $6) aoud ON (cp.circ_lib = aoud.id) WHERE cp.call_number = acn.id + AND cp.deleted IS FALSE ORDER BY COALESCE(cp.copy_number,0), cp.barcode LIMIT ($7 -> 'acp')::INT OFFSET ($8 -> 'acp')::INT @@ -865,6 +873,7 @@ CREATE OR REPLACE FUNCTION unapi.acn ( obj_id BIGINT, format TEXT, ename TEXT, FROM asset.copy cp JOIN actor.org_unit_descendants( (SELECT id FROM actor.org_unit WHERE shortname = $5) ) aoud ON (cp.circ_lib = aoud.id) WHERE cp.call_number = acn.id + AND cp.deleted IS FALSE ORDER BY COALESCE(cp.copy_number,0), cp.barcode LIMIT ($7 -> 'acp')::INT OFFSET ($8 -> 'acp')::INT @@ -884,6 +893,7 @@ CREATE OR REPLACE FUNCTION unapi.acn ( obj_id BIGINT, format TEXT, ename TEXT, FROM asset.call_number acn JOIN actor.org_unit o ON (o.id = acn.owning_lib) WHERE acn.id = $1 + AND acn.deleted IS FALSE GROUP BY acn.id, o.shortname, o.opac_visible, deleted, label, label_sortkey, label_class, owning_lib, record, acn.prefix, acn.suffix; $F$ LANGUAGE SQL;