From b9d5b49cc209b2af9f14e86f8655ef49b4d2558c Mon Sep 17 00:00:00 2001 From: Chris Sharp Date: Fri, 14 Sep 2018 14:57:57 -0400 Subject: [PATCH] Fix Circulation by MARC item type query. Previously, this query was making use of the "circ_as_type" item attribute, which is not the same thing as the MARC type of the item, which is defined in the fixed field of the MARC record. --- perl/execreports/erqueries.pl | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/perl/execreports/erqueries.pl b/perl/execreports/erqueries.pl index 52dbc79..4ab0b0f 100755 --- a/perl/execreports/erqueries.pl +++ b/perl/execreports/erqueries.pl @@ -235,16 +235,20 @@ c3 => <<"SQL", INSERT INTO $collection_table (time_stamp, year_month, report, sub_report, org_unit, data) ( -SELECT now(), $year_month, 'C3', asset.copy.circ_as_type, actor.org_unit.id, COUNT(action.circulation.id) -FROM action.circulation - INNER JOIN actor.org_unit ON action.circulation.circ_lib = actor.org_unit.id - INNER JOIN asset.copy ON action.circulation.target_copy = asset.copy.id -WHERE actor.org_unit.id in (SELECT id from actor.org_unit WHERE ou_type=3) - AND date(action.circulation.xact_start) BETWEEN '$start_date' AND '$end_date' -GROUP BY actor.org_unit.id, asset.copy.circ_as_type +SELECT now(), $year_month, 'C3', metabib.record_attr_flat.value, actor.org_unit.id, COUNT(action.circulation.id) +FROM action.circulation + INNER JOIN actor.org_unit ON action.circulation.circ_lib = actor.org_unit.id + INNER JOIN asset.copy ON action.circulation.target_copy = asset.copy.id + INNER JOIN asset.call_number ON (asset.copy.call_number = asset.call_number.id) + INNER JOIN metabib.record_attr_flat ON (asset.call_number.record = metabib.record_attr_flat.id AND metabib.record_attr_flat.attr = 'item_type') +WHERE actor.org_unit.id in (SELECT id from actor.org_unit WHERE ou_type=3) + AND date(action.circulation.xact_start) BETWEEN '$start_date' AND '$end_date' +GROUP BY actor.org_unit.id, metabib.record_attr_flat.value ) SQL + + c3systems => <<"SQL", INSERT INTO $collection_table (time_stamp, year_month, report, sub_report, org_unit, data) -- 2.11.0