From: Rogan Hamby Date: Wed, 17 Apr 2019 15:12:37 +0000 (-0400) Subject: adding last_circ_lib into collectionhq items script X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=d6833c5d0141a5003d2bf63a53ad5d515d491e0e;p=contrib%2Fequinox.git adding last_circ_lib into collectionhq items script --- diff --git a/collectionHQ/functions.sql b/collectionHQ/functions.sql index 84028da..3513762 100644 --- a/collectionHQ/functions.sql +++ b/collectionHQ/functions.sql @@ -89,6 +89,7 @@ CREATE OR REPLACE FUNCTION collectionHQ.write_item_rows_to_stdout (TEXT, INT) RE org_unit_id ALIAS for $2; lms_bib_id BIGINT; library_code TEXT; + last_circ_lib TEXT; bar_code TEXT; last_use_date TEXT; cumulative_use_total TEXT; @@ -140,6 +141,8 @@ CREATE OR REPLACE FUNCTION collectionHQ.write_item_rows_to_stdout (TEXT, INT) RE END IF; SELECT REPLACE(NOW()::DATE::TEXT, '-', '') INTO extract_date; SELECT ou.shortname INTO library_code FROM actor.org_unit ou, asset.copy c WHERE ou.id = c.circ_lib AND c.id = item; + SELECT aou.shortname, REPLACE(circ.xact_start::DATE::TEXT, '-', '') INTO last_circ_lib, last_use_date FROM actor.org_unit aou INNER JOIN action.circulation circ ON (circ.circ_lib = aou.id) + WHERE circ.target_copy = item ORDER BY circ.xact_start DESC LIMIT 1; SELECT REPLACE(xact_start::DATE::TEXT, '-', '') INTO last_use_date FROM action.circulation WHERE target_copy = item ORDER BY xact_start DESC LIMIT 1; SELECT circ_count INTO cumulative_use_total FROM extend_reporter.full_circ_count WHERE id = item; IF cumulative_use_total IS NULL THEN @@ -169,6 +172,7 @@ CREATE OR REPLACE FUNCTION collectionHQ.write_item_rows_to_stdout (TEXT, INT) RE || lms_bib_id || ',' || COALESCE(collectionHQ.quote(authority_code), '') || ',' || COALESCE(collectionHQ.quote(library_code), '') || ',' + || COALESCE(collectionHQ.quote(last_circ_lib), '') || ',' || COALESCE(collectionHQ.quote(bar_code), '') || ',' || COALESCE(collectionHQ.quote(last_use_date), '') || ',' || COALESCE(cumulative_use_total, '') || ','