From: Bill Erickson Date: Mon, 20 Jan 2014 15:21:30 +0000 (-0500) Subject: LP#1053397 unapi.mmr() gets new slimit->bre limit X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=df85d3e9ef66a3fb8935bd4cca50c19319b8edd8;p=working%2FEvergreen.git LP#1053397 unapi.mmr() gets new slimit->bre limit Support limiting the number of constituent records to flesh into a metarecord. This carries particular weight when fleshing holdings, since a large number of constituent records could produce very large documents. Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.unapi-mmr.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.unapi-mmr.sql index 6fe1fde79a..e2f1225a99 100644 --- a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.unapi-mmr.sql +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.unapi-mmr.sql @@ -89,14 +89,14 @@ BEGIN hxml := NULL::XML; subxml := NULL::XML; - FOR subrec IN SELECT * FROM biblio.record_entry bre - JOIN metabib.metarecord_source_map mmsm ON (mmsm.metarecord = mmr_id) - WHERE mmsm.source = bre.id LOOP - - -- collect holdings for all records - -- XXX: holdings limits and offsets are applied individually to each - -- subordinate record. This could lead to large XML blobs for - -- large metarecords. Does this need to change? + FOR subrec IN SELECT bre.* FROM biblio.record_entry bre + JOIN metabib.metarecord_source_map mmsm ON (mmsm.source = bre.id) + JOIN metabib.metarecord mmr ON (mmr.id = mmsm.metarecord) + WHERE mmr.id = mmr_id + ORDER BY CASE WHEN bre.id = mmr.master_record THEN 0 ELSE bre.id END + LIMIT COALESCE((slimit->'bre')::INT, 5) LOOP + + -- collect holdings for all added records IF ('holdings_xml' = ANY (includes)) THEN hxml := XMLCONCAT(hxml, unapi.holdings_xml( subrec.id, ouid, org, depth, @@ -105,8 +105,8 @@ BEGIN END IF; IF subrec.id = leadrec.id THEN CONTINUE; END IF; - -- Append choice data from the XML of the non-lead records to the - -- XML of the lead record + -- Append choice data from the the non-lead records to the + -- the lead record document FOREACH xml_frag IN ARRAY (SELECT * FROM xpath(sub_xpath, subrec.marc::XML)) LOOP @@ -134,7 +134,7 @@ BEGIN END IF; -- update top_el to reflect the change in xml_buf, which may - -- now be a wholly different type of document (e.g. record -> mods) + -- now be a different type of document (e.g. record -> mods) top_el := REGEXP_REPLACE(xml_buf, E'^.*?<((?:\\S+:)?' || layout.holdings_element || ').*$', E'\\1'); @@ -143,7 +143,7 @@ BEGIN '(.*?)$', axml || '\\1'); END IF; - IF hxml IS NOT NULL THEN -- XXX how do we configure the holdings position? + IF hxml IS NOT NULL THEN xml_buf := REGEXP_REPLACE(xml_buf, '(.*?)$', hxml || '\\1'); END IF;