1 -- Evergreen DB patch 0688.data.circ_history_export_csv.sql
3 -- FIXME: insert description of change, if needed
7 -- check whether patch can be applied
8 SELECT evergreen.upgrade_deps_block_check('0688', :eg_version);
10 INSERT INTO action_trigger.hook (key, core_type, description, passive)
12 'circ.format.history.csv',
15 'circ.format.history.csv',
16 'Produce CSV of circulation history',
23 INSERT INTO action_trigger.event_definition (
24 active, owner, name, hook, reactor, validator, group_field, template)
26 TRUE, 1, 'Circ History CSV', 'circ.format.history.csv', 'ProcessTemplate', 'NOOP_True', 'usr',
28 Title,Author,Call Number,Barcode,Format
31 bibxml = helpers.unapi_bre(circ.target_copy.call_number.record, {flesh => '{mra}'});
33 FOR part IN bibxml.findnodes('//*[@tag="245"]/*[@code="a" or @code="b"]');
34 title = title _ part.textContent;
36 author = bibxml.findnodes('//*[@tag="100"]/*[@code="a"]').textContent;
37 item_type = bibxml.findnodes('//*[local-name()="attributes"]/*[local-name()="field"][@name="item_type"]').getAttribute('coded-value') %]
39 [%- helpers.csv_datum(title) -%],
40 [%- helpers.csv_datum(author) -%],
41 [%- helpers.csv_datum(circ.target_copy.call_number.label) -%],
42 [%- helpers.csv_datum(circ.target_copy.barcode) -%],
43 [%- helpers.csv_datum(item_type) %]
48 INSERT INTO action_trigger.environment (event_def, path)
50 currval('action_trigger.event_definition_id_seq'),
51 'target_copy.call_number'