m_ prefix for staging tables
[migration-tools.git] / mig-xml / evergreen_staged_report.xml
1 <reports_file>
2     <function>
3         <name>find_cmm</name>
4         <drop>DROP FUNCTION IF EXISTS find_cmm(BIGINT)</drop>
5         <create>
6             CREATE OR REPLACE FUNCTION find_cmm(circ_id BIGINT)
7                 RETURNS SETOF INTEGER[]
8                 LANGUAGE plpgsql
9             AS $function$
10             DECLARE
11                  aou     INTEGER;
12                  ac      INTEGER;
13                  au      INTEGER;
14                  r       INTEGER[];
15             BEGIN
16                 SELECT circ_lib FROM action.circulation WHERE id = circ_id INTO aou;
17                 SELECT target_copy FROM action.circulation WHERE id = circ_id INTO ac;
18                 SELECT usr FROM action.circulation WHERE id = circ_id INTO au;
19
20                 FOR r IN SELECT buildrows FROM action.find_circ_matrix_matchpoint(aou,ac,au,FALSE)
21                     LOOP
22                         RETURN NEXT r;
23                     END LOOP;
24                 RETURN;
25             END
26         $function$</create>
27     </function>
28
29
30 <!-- sample reports entry
31     <report>
32         <name>name of report</name>
33         <iteration value='0' /> which version, the first version to run is 0, first backup is 1, then so on
34         <tag>money</tag>  arbitrary tags, each should go in separate tag
35         <report_title>Migrated Billings</report_title>  title used in the asciidoc output
36         <heading column='1'>Number of Billings.Migrated.Total</heading> period delimited 
37         <query>SELECT COUNT(id),x_migrate::TEXT,SUM(amount) FROM m_money_billing_legacy GROUP BY 2;</query>  query itself, will be replaced
38         <note>Arbitrary note that can be included in the entries.</note>
39     </report>
40 -->
41
42     <!-- CIRC REPORTS -->
43     <report>
44         <name>circ_count</name>
45         <tag>circs</tag>
46         <iteration>0</iteration>
47         <report_title>Migrated Circulations</report_title>
48         <heading>Circulation Status.Count of Circs</heading>
49         <query>SELECT 'Closed Circulations', COUNT(id) FROM m_action_circulation_legacy WHERE xact_finish IS NOT NULL AND x_migrate 
50             UNION ALL SELECT 'Open Circulations', COUNT(id) FROM m_action_circulation_legacy WHERE xact_finish IS NULL AND x_migrate</query>
51     </report>
52
53     <report>
54         <name>circ_count_unmigrated</name>
55         <tag>circs</tag>
56         <iteration>0</iteration>
57         <report_title>Open Un-migrated Circulations</report_title>
58         <heading>Circulation Status.Count of Circs</heading>
59         <query>SELECT 'No Matching User', COUNT(id) FROM m_action_circulation_legacy WHERE xact_finish IS NULL AND x_migrate = FALSE AND usr IS NULL 
60                 UNION ALL SELECT 'No Matching Item', COUNT(id) FROM m_action_circulation_legacy WHERE xact_finish IS NULL AND x_migrate = FALSE AND target_copy IS NULL </query>
61     </report>
62
63     <report>
64         <name>circ_count</name>
65         <tag>circs</tag>
66         <iteration>1</iteration>
67         <report_title>Open Circulations</report_title>
68         <heading>Circulation Status.Count of Circs</heading>
69         <query>SELECT 'Closed Circulations', COUNT(id) FROM m_action_circulation WHERE xact_finish IS NOT NULL UNION ALL SELECT 'Open Circulations', COUNT(id) FROM m_action_circulation WHERE xact_finish IS NULL</query>
70     </report>
71 <!-- intent is to add a report by circulated and item status
72     <report>
73         <name>circ_count_by_item_status</name>
74         <tag>circs</tag>
75         <iteration>0</iteration>
76         <report_title>Open Circulations</report_title>
77         <heading>Circulation Status.Migrated.Count of Circs</heading>
78         <query>SELECT 'Closed Circulations', x_migrate::TEXT, COUNT(id) FROM m_action_circulation_legacy WHERE xact_finish IS NOT NULL GROUP BY 2 UNION ALL SELECT 'Open Circulations', x_migrate::TEXT, COUNT(id) FROM m_action_circulation_legacy WHERE xact_finish IS NULL GROUP BY 2</query>
79     </report>
80 -->
81      <report>
82         <name>circ_by_orgunit</name>
83         <tag>circs</tag>
84         <iteration>0</iteration>
85         <report_title>Circulations by Org Unit</report_title>
86         <heading>Circulations Count.Migrated.Org Unit</heading>
87         <query>SELECT COUNT(acirc.id), acirc.x_migrate::TEXT, aou.name FROM m_action_circulation_legacy acirc JOIN actor.org_unit aou ON aou.id = acirc.circ_lib WHERE acirc.xact_finish IS NULL GROUP BY 2, 3</query>
88     </report>
89
90      <report>
91         <name>circ_by_orgunit</name>
92         <tag>circs</tag>
93         <iteration>1</iteration>
94         <report_title>Circulations by Org Unit</report_title>
95         <heading>Circulations Count.Org Unit</heading>
96         <query>SELECT COUNT(acirc.id), aou.name FROM m_action_circulation acirc JOIN actor.org_unit aou ON aou.id = acirc.circ_lib WHERE acirc.xact_finish IS NULL GROUP BY 2</query>
97     </report>
98
99      <report>
100         <name>circs_by_duration</name>
101         <tag>circs</tag>
102         <iteration>0</iteration>
103         <report_title>Migrated Circulations by Duration, Fine and Max Fine</report_title>
104         <heading>Count of Circs.Duration.Fine.Max Fine.Migrated</heading>
105         <query>SELECT COUNT(id), duration_rule, recurring_fine_rule, max_fine_rule, x_migrate::TEXT FROM m_action_circulation_legacy WHERE x_migrate = TRUE GROUP BY 2, 3, 4, 5</query>
106     </report>
107
108      <report>
109         <name>circs_by_duration</name>
110         <tag>circs</tag>
111         <iteration>1</iteration>
112         <report_title>Circulations by Duration, Fine and Max Fine</report_title>
113         <heading>Count of Circs.Duration.Fine.Max Fine</heading>
114         <query>SELECT COUNT(id), duration_rule, recurring_fine_rule, max_fine_rule FROM m_action_circulation GROUP BY 2, 3, 4 ORDER BY 2, 3, 4</query>
115     </report>
116
117      <report>
118         <name>circs_by_usrgroup</name>
119         <tag>circs</tag>
120         <iteration>0</iteration>
121         <report_title>Circulations by Rules and Patron Group</report_title>
122         <heading>Count of Circs.Duration.Fine.Max Fine.User Group.Matchpoints</heading>
123         <query>SELECT COUNT(acirc.id), acirc.duration_rule, acirc.recurring_fine_rule, acirc.max_fine_rule, pgt.name, x.buildrows FROM m_action_circulation_legacy acirc JOIN actor.usr au ON au.id = acirc.usr JOIN permission.grp_tree pgt ON pgt.id = au.profile JOIN (SELECT acirc.id, ARRAY_TO_STRING(find_cmm(acirc.id),',') AS buildrows FROM m_action_circulation_legacy acirc WHERE acirc.x_migrate = TRUE) x ON x.id = acirc.id WHERE acirc.x_migrate = TRUE GROUP BY 2, 3, 4, 5, 6 ORDER BY 2, 3, 4, 5, 6</query>
124     </report>
125
126      <report>
127         <name>circs_by_usrgroup</name>
128         <tag>circs</tag>
129         <iteration>1</iteration>
130         <report_title>Circulations by Rules and Patron Group</report_title>
131         <heading>Count of Circs.Duration.Fine.Max Fine.User Group.Matchpoints</heading>
132         <query>SELECT COUNT(acirc.id), acirc.duration_rule, acirc.recurring_fine_rule, acirc.max_fine_rule, pgt.name, x.buildrows FROM m_action_circulation acirc JOIN actor.usr au ON au.id = acirc.usr JOIN permission.grp_tree pgt ON pgt.id = au.profile JOIN (SELECT acirc.id, ARRAY_TO_STRING(find_cmm(acirc.id),',') AS buildrows FROM m_action_circulation acirc) x ON x.id = acirc.id GROUP BY 2, 3, 4, 5, 6 ORDER BY 2, 3, 4, 5, 6</query>
133     </report>
134
135      <report>
136         <name>circs_by_circmod</name>
137         <tag>circs</tag>
138         <iteration>0</iteration>
139         <report_title>Circulations by Rules and Circulation Modifier</report_title>
140         <heading>Count of Circs.Duration.Fine.Max Fine.Circulation Modifier.Matchpoints</heading>
141         <query>SELECT COUNT(acirc.id), acirc.duration_rule, acirc.recurring_fine_rule, acirc.max_fine_rule, ac.circ_modifier, x.buildrows FROM m_action_circulation_legacy acirc JOIN asset.copy ac ON ac.id = acirc.target_copy JOIN (SELECT acirc.id, ARRAY_TO_STRING(find_cmm(acirc.id),',') AS buildrows FROM m_action_circulation_legacy acirc WHERE acirc.x_migrate = TRUE) x ON x.id = acirc.id WHERE acirc.x_migrate = TRUE GROUP BY 2, 3, 4, 5, 6 ORDER BY 2, 3, 4, 5, 6</query>
142     </report>
143
144      <report>
145         <name>circs_by_circmod</name>
146         <tag>circs</tag>
147         <iteration>1</iteration>
148         <report_title>Circulations by Rules and Circulation Modifier</report_title>
149         <heading>Count of Circs.Duration.Fine.Max Fine.Circulation Modifier.Matchpoints</heading>
150         <query>SELECT COUNT(acirc.id), acirc.duration_rule, acirc.recurring_fine_rule, acirc.max_fine_rule, ac.circ_modifier, x.buildrows FROM m_action_circulation acirc JOIN asset.copy ac ON ac.id = acirc.target_copy JOIN (SELECT acirc.id, ARRAY_TO_STRING(find_cmm(acirc.id),',') AS buildrows FROM m_action_circulation acirc) x ON x.id = acirc.id
151              GROUP BY 2, 3, 4, 5, 6 ORDER BY 2, 3, 4, 5, 6</query>
152     </report>
153
154      <report>
155         <name>circs_by_orgunit</name>
156         <tag>circs</tag>
157         <iteration>0</iteration>
158         <report_title>Circulations by Rules and Org Unit</report_title>
159         <heading>Count of Circs.Duration.Fine.Max Fine.Library Branch</heading>
160         <query>SELECT COUNT(acirc.id), acirc.duration_rule, acirc.recurring_fine_rule, acirc.max_fine_rule, aou.name FROM m_action_circulation_legacy acirc JOIN actor.org_unit aou ON aou.id = acirc.circ_lib WHERE acirc.x_migrate = TRUE GROUP BY 2, 3, 4, 5 ORDER BY 2, 3, 4, 5</query>
161     </report>
162
163      <report>
164         <name>circs_by_orgunit</name>
165         <tag>circs</tag>
166         <iteration>1</iteration>
167         <report_title>Circulations by Rules and Org Unit</report_title>
168         <heading>Count of Circs.Duration.Fine.Max Fine.Library Branch</heading>
169         <query>SELECT COUNT(acirc.id), acirc.duration_rule, acirc.recurring_fine_rule, acirc.max_fine_rule, aou.name FROM m_action_circulation acirc JOIN actor.org_unit aou ON aou.id = acirc.circ_lib GROUP BY 2, 3, 4, 5 ORDER BY 2, 3, 4, 5</query>
170     </report>
171
172      <report>
173         <name>non_cat_circs</name>
174         <tag>circs</tag>
175         <iteration>0</iteration>
176         <report_title>Non-Cataloged Circulation</report_title>
177         <heading>Circulations Count.Migrated</heading>
178         <query>SELECT COUNT(id), x_migrate::TEXT FROM m_action_non_cataloged_circulation_legacy GROUP BY 2</query>
179     </report>
180
181      <report>
182         <name>non_cat_circs</name>
183         <tag>circs</tag>
184         <iteration>1</iteration>
185         <report_title>Non-Cataloged Circulation</report_title>
186         <heading>Circulations Count</heading>
187         <query>SELECT COUNT(id) FROM m_action_non_cataloged_circulation</query>
188     </report>
189
190      <report>
191         <name>in_house</name>
192         <tag>circs</tag>
193         <iteration>0</iteration>
194         <report_title>In House Use</report_title>
195         <heading>In House Use Records.Migrated</heading>
196         <query>SELECT COUNT(id), x_migrate::TEXT FROM m_action_in_house_use_legacy GROUP BY 2</query>
197     </report>
198
199      <report>
200         <name>in_house</name>
201         <tag>circs</tag>
202         <iteration>1</iteration>
203         <report_title>In House Use</report_title>
204         <heading>In House Use Records</heading>
205         <query>SELECT COUNT(id) FROM m_action_in_house_use</query>
206     </report>
207
208      <report>
209         <name>circs_missing_rules</name>
210         <tag>circs</tag>
211         <iteration>1</iteration>
212         <report_title>Circs Missing Rules</report_title>
213         <heading>Count.Field Missing</heading>
214         <query>SELECT COUNT(id), 'Duration Rule Value' FROM m_action_circulation WHERE duration IS NULL 
215             UNION ALL SELECT COUNT(id), 'Recurring Fine Rule Value' FROM m_action_circulation WHERE recurring_fine IS NULL 
216             UNION ALL SELECT COUNT(id), 'Max Fine Rule Value' FROM m_action_circulation WHERE max_fine IS NULL
217             UNION ALL SELECT COUNT(id), 'Duration Rule' FROM m_action_circulation WHERE duration_rule IS NULL       
218             UNION ALL SELECT COUNT(id), 'Recurring Fine Rule' FROM m_action_circulation WHERE recurring_fine_rule IS NULL      
219             UNION ALL SELECT COUNT(id), 'Max Fine Rule' FROM m_action_circulation WHERE max_fine_rule IS NULL
220         </query>
221     </report>
222
223      <report>
224         <name>circ_open_by_item_status</name>
225         <tag>circs</tag>
226         <iteration>0</iteration>
227         <report_title>Open Circulation and Status of Linked Items</report_title>
228         <heading>Count.Status</heading>
229         <query>SELECT COUNT(acirc.id), ccs.name FROM action.circulation acirc JOIN asset.copy ac ON ac.id = acirc.target_copy JOIN config.copy_status ccs ON ccs.id = ac.status WHERE acirc.xact_finish IS NULL AND acirc.checkin_time IS NULL AND acirc.id IN (SELECT id FROM m_action_circulation) GROUP BY 2 ORDER BY 2</query>
230     </report>
231
232     <!-- HOLDS REPORTS -->
233
234      <report>
235         <name>holds</name>
236         <tag>holds</tag>
237         <iteration>0</iteration>
238         <report_title>Migrated Holds</report_title>
239         <heading>Hold Type.Hold Count.Migrated</heading>
240         <query>SELECT 'Closed Holds', COUNT(id), x_migrate::TEXT FROM m_action_hold_request_legacy WHERE (expire_time::TIMESTAMP &lt; now()) OR cancel_time IS NOT NULL OR fulfillment_time IS NOT NULL GROUP BY 3 UNION ALL SELECT 'Open Holds', COUNT(id), x_migrate::TEXT FROM m_action_hold_request_legacy WHERE (expire_time IS NULL OR expire_time::TIMESTAMP &gt; now()) AND cancel_time IS NULL AND fulfillment_time IS NULL GROUP BY 3</query>
241     </report>
242
243      <report>
244         <name>holds_bytype</name>
245         <tag>holds</tag>
246         <iteration>0</iteration>
247         <report_title>Migrated Holds By Type</report_title>
248         <heading>Hold Type.Hold Count.Migrated</heading>
249         <query>SELECT hold_type as "Hold Type", COUNT(id), x_migrate::TEXT FROM m_action_hold_request_legacy GROUP BY 1, 3</query>
250     </report>
251
252      <report>
253         <name>transit_open_by_item_status</name>
254         <tag>holds</tag>
255         <iteration>0</iteration>
256         <report_title>Transit Copy Records and Status of Linked Items</report_title>
257         <heading>Count.Status</heading>
258         <query>SELECT COUNT(atc.id), ccs.name FROM action.transit_copy atc JOIN asset.copy ac ON ac.id = atc.target_copy JOIN config.copy_status ccs ON ccs.id = ac.status WHERE atc.id IN (SELECT id FROM m_action_transit_copy) AND atc.dest_recv_time IS NULL GROUP BY 2 ORDER BY 2</query>
259     </report>
260
261      <report>
262         <name>transit_copies_by_status</name>
263         <tag>holds</tag>
264         <iteration>0</iteration>
265         <report_title>Status of Items with Count of Open In Transits</report_title>
266         <heading>Count.Status.Count of Open Transits</heading>
267         <query>SELECT COUNT(ac.id), ccs.name, SUM(CASE WHEN atc.id IS NULL THEN 0 ELSE 1 END) FROM asset.copy ac JOIN config.copy_status ccs ON ccs.id = ac.status LEFT JOIN (SELECT * FROM action.transit_copy WHERE id IN (SELECT id FROM m_action_transit_copy) AND dest_recv_time IS NULL) atc ON atc.target_copy = ac.id WHERE ac.id IN (SELECT id from m_asset_copy) GROUP BY 2 ORDER BY 2</query>
268     </report>
269     
270      <report>
271         <name>hold_copies_by_status</name>
272         <tag>holds</tag>
273         <iteration>0</iteration>
274         <report_title>Captured Holds with Status of Items</report_title>
275         <heading>Count of Captured Hold.Status of Item</heading>
276         <query>SELECT COUNT(ahr.id), ccs.name FROM action.hold_request ahr JOIN asset.copy ac ON ac.id = ahr.current_copy JOIN config.copy_status ccs ON ccs.id = ac.status WHERE ahr.capture_time IS NOT NULL AND ahr.fulfillment_time IS NULL and ahr.cancel_time IS NULL AND ahr.id IN (SELECT id FROM m_action_hold_request) GROUP BY 2 ORDER By 2</query>
277     </report>
278
279       <report>
280         <name>hold_depth</name>
281         <tag>holds</tag>
282         <iteration>0</iteration>
283         <report_title>Depth of Unfilled Holds</report_title>
284         <heading>Count.Depth</heading>
285         <query>SELECT COUNT(ahr.id), ahr.selection_depth FROM action.hold_request ahr WHERE ahr.id IN (SELECT id FROM m_action_hold_request) AND ahr.cancel_time IS NULL AND ahr.capture_time IS NULL AND ahr.fulfillment_time IS NULL GROUP BY 2 ORDER BY 2</query>
286     </report>
287
288       <!-- finding title matched holds where there are duplicates, this will table match for legacy but column won't be present for all  -->
289       <report>
290         <name>duplicate_title_matching_holds</name>
291         <tag>holds</tag>
292         <iteration>0</iteration>
293         <report_title>Holds by Title Matchs</report_title>
294         <heading>Count.Number of Matches</heading>
295         <query>SELECT COUNT(*), x_title_matches FROM m_action_hold_request_legacy WHERE TO_DATE(l_expire_date,'MM/DD/YYYY') > NOW() GROUP BY 2 ORDER BY 2</query>
296     </report>
297
298       <report>
299         <name>duplicate_title_matching_holds_w_zero</name>
300         <tag>holds</tag>
301         <iteration>0</iteration>
302         <report_title>Sample of Holds with No Matches</report_title>
303         <heading>Borrower Barcode.Title.Request Date</heading>
304         <query>SELECT l_borrower_id, l_title, l_request_date FROM m_action_hold_request_legacy WHERE TO_DATE(l_expire_date,'MM/DD/YYYY') > NOW() AND x_title_matches = 0 AND x_migrate LIMIT 20</query>
305     </report>
306
307       <report>
308         <name>duplicate_title_matching_holds_w_greater_than_1</name>
309         <tag>holds</tag>
310         <iteration>0</iteration>
311         <report_title>Sample of Holds with More Than One Title Match</report_title>
312         <heading>Borrower Barcode.Title.Request Date</heading>
313         <query>SELECT l_borrower_id, l_title, l_request_date FROM m_action_hold_request_legacy WHERE TO_DATE(l_expire_date,'MM/DD/YYYY') > NOW() AND x_title_matches > 1 AND x_migrate LIMIT 20</query>
314     </report>
315
316     <!-- ASSET REPORTS -->
317     
318     <report>
319         <name>m_asset_copy_count</name>
320         <report_title>Count of Copies by Library</report_title>
321         <tag>assets</tag>
322         <iteration>0</iteration>
323         <heading>Copy Count.Library.Migrated</heading>
324         <query>SELECT COUNT(ac.id), aou.name, ac.x_migrate::TEXT FROM m_asset_copy_legacy ac JOIN actor.org_unit aou ON aou.id = ac.circ_lib GROUP BY 2, 3 ORDER BY 2, 3</query>
325     </report>
326
327     <report>
328         <name>m_asset_deleted_copies</name>
329         <report_title>Deleted Copies</report_title>
330         <tag>assets</tag>
331         <iteration>0</iteration>
332         <heading>Copy Count.Deleted.Migrated</heading>
333         <query>SELECT COUNT(ac.id), ac.deleted::TEXT, ac.x_migrate::TEXT FROM m_asset_copy_legacy ac GROUP BY 2, 3</query>
334     </report>
335
336     <report>
337         <name>m_asset_copies_by_status</name>
338         <report_title>Copies by Status</report_title>
339         <tag>assets</tag>
340         <iteration>0</iteration>
341         <heading>Copy Count.Status.Migrated</heading>
342         <query>SELECT COUNT(ac.id), cs.name, ac.x_migrate::TEXT FROM m_asset_copy_legacy ac JOIN config.copy_status cs ON cs.id = ac.status GROUP BY 2, 3 ORDER BY 2, 3</query>
343     </report>
344
345     <report>
346         <name>m_asset_precat</name>
347         <report_title>Precats (AKA Copies Without Bibs)</report_title>
348         <tag>assets</tag>
349         <iteration>0</iteration>
350         <heading>Copy Count.Migating</heading>
351         <query>SELECT COUNT(ac.id), ac.x_migrate::TEXT FROM m_asset_copy_legacy ac WHERE ac.x_bre_id = -1 GROUP BY 2</query>
352     </report>
353
354     <report>
355         <name>m_asset_circ_mod_copies_count</name>
356         <report_title>Copies by Circulation Modifier</report_title>
357         <tag>assets</tag>
358         <iteration>0</iteration>
359         <heading>Copy Count.Circulation Modifier.Migrated</heading>
360         <query>SELECT COUNT(ac.id), ac.circ_modifier, ac.x_migrate::TEXT FROM m_asset_copy_legacy ac GROUP BY 2, 3 ORDER BY 2, 3</query>
361     </report>
362
363     <report>
364         <name>m_asset_copy_notes</name>
365         <report_title>Copy Notes</report_title>
366         <tag>assets</tag>
367         <iteration>0</iteration>
368         <heading>Note Count.Public.Migrated</heading>
369         <query>SELECT COUNT(acnote.id), acnote.pub::TEXT, acnote.x_migrate::TEXT FROM m_asset_copy_note_legacy acnote GROUP BY 2, 3 ORDER BY 2, 3</query>
370     </report>
371
372     <report>
373         <name>m_asset_copy_notes</name>
374         <report_title>Copy Notes</report_title>
375         <tag>assets</tag>
376         <iteration>1</iteration>
377         <heading>Note Count.Public</heading>
378         <query>SELECT COUNT(acnote.id), acnote.pub::TEXT FROM m_asset_copy_note acnote GROUP BY 2 ORDER BY 2</query>
379     </report>
380
381    <report>
382         <name>m_asset_vols_by_lib</name>
383         <report_title>Volumes by Library</report_title>
384         <tag>assets</tag>
385         <iteration>0</iteration>
386         <heading>Volume Count.Library.Migrated</heading>
387         <query>SELECT COUNT(acn.id), aou.name, acn.x_migrate::TEXT FROM m_asset_call_number_legacy acn JOIN m_actor_org_unit_legacy aou ON aou.id = acn.owning_lib GROUP BY 2, 3 ORDER BY 2, 3</query>
388     </report>
389
390    <report>
391         <name>m_asset_vols_by_lib</name>
392         <report_title>Volumes by Library</report_title>
393         <tag>assets</tag>
394         <iteration>1</iteration>
395         <heading>Volume Count.Library</heading>
396         <query>SELECT COUNT(acn.id), aou.name FROM m_asset_call_number acn JOIN actor.org_unit aou ON aou.id = acn.owning_lib GROUP BY 2 ORDER BY 2</query>
397     </report>
398     <!--
399    <report>
400         <name>m_asset_cops_by_loc</name>
401         <report_title>Copies by Location</report_title>
402         <tag>assets</tag>
403         <iteration>0</iteration>
404         <heading>Copy Count.Library.Migrated</heading>
405         <query>SELECT COUNT(ac.id), acl.name, ac.x_migrate::TEXT FROM m_asset_copy_legacy ac JOIN asset.copy_location acl ON acl.id = ac.location GROUP BY 2, 3 ORDER BY 2, 3</query>
406     </report>
407    -->
408    <report>
409         <name>m_asset_cops_by_loc_and_org</name>
410         <report_title>Copies by Location</report_title>
411         <tag>assets</tag>
412         <iteration>0</iteration>
413         <heading>Copy Count.Library.Circ Library.Migrated</heading>
414         <query>SELECT COUNT(ac.id), acl.name, aou.name, ac.x_migrate::TEXT FROM m_asset_copy_legacy ac JOIN asset.copy_location acl ON acl.id = ac.location JOIN actor.org_unit aou ON aou.id = ac.circ_lib GROUP BY 2, 3, 4 ORDER BY 2, 3, 4</query>
415     </report>
416
417    <report>
418         <name>m_asset_cops_w_loc_one</name>
419         <report_title>Copies with a Location of Stacks</report_title>
420         <tag>assets</tag>
421         <iteration>0</iteration>
422         <heading>Barcode</heading>
423         <query>SELECT barcode FROM m_asset_copy_legacy WHERE location = 1 AND x_migrate</query>
424     </report>
425
426     <!-- report>
427         <name>m_asset_barcode_lengths</name>
428         <report_title>Barcode Lengths by Library</report_title>
429         <tag>assets</tag>
430         <iteration>0</iteration>
431         <heading>Count of Barcode.Barcode Length.Library</heading>
432         <query>SELECT COUNT(ac.id), LENGTH(ac.barcode), aou.name FROM m_asset_copy_legacy ac JOIN actor.org_unit aou ON aou.id = ac.circ_lib WHERE ac.x_migrate = TRUE GROUP BY 2, 3 ORDER BY 3, 2</query>
433     </report -->
434
435     <report>
436         <name>m_asset_no_barcode</name>
437         <report_title>Items Without Barcodes</report_title>
438         <tag>assets</tag>
439         <iteration>0</iteration>
440         <heading>Assigned Barcode</heading>
441         <query>SELECT barcode FROM m_asset_copy_legacy WHERE barcode ~* 'no_barocde' AND x_migrate</query>
442     </report>
443
444     <report>
445         <name>m_asset_barcode_patterns</name>
446         <report_title>Common Barcode Starting Patterns</report_title>
447         <tag>assets</tag>
448         <iteration>0</iteration>
449         <heading>Count of Barcodes (greater than 10).Left 60% of Characters</heading>
450         <query>SELECT COUNT(ac.id), LEFT(ac.barcode,(ROUND(LENGTH(ac.barcode)*.6))::INT) FROM m_asset_copy_legacy ac WHERE ac.x_migrate = TRUE GROUP BY 2 HAVING COUNT(ac.id) > 10 ORDER BY 2</query>
451     </report>
452
453     <report>
454         <name>m_asset_barcode_collisions</name>
455         <report_title>Copy Barcode Collisions</report_title>
456         <tag>assets</tag>
457         <iteration>0</iteration>
458         <heading>Collision Count</heading>
459         <query>SELECT COUNT(id) FROM m_asset_copy_legacy WHERE x_migrate = TRUE AND barcode LIKE 'x_%'</query>
460         <note>Incumbent collisions are those where the migrated barcodes collide with existing barcodes in the database.</note>
461     </report>
462
463     <report>
464         <name>m_asset_barcode_collisions</name>
465         <report_title>Copy Barcode Collisions</report_title>
466         <tag>assets</tag>
467         <iteration>1</iteration>
468         <heading>Collision Count</heading>
469         <query>SELECT COUNT(id) FROM m_asset_copy WHERE barcode LIKE 'x_%'</query>
470         <note>Incumbent collisions are those where the migrated barcodes collide with existing barcodes in the database.</note>
471     </report>
472
473     <report>
474         <name>m_asset_barcode_collisions_shortlist</name>
475         <report_title>Copy Barcode Collisions (first 20)</report_title>
476         <tag>assets</tag>
477         <iteration>0</iteration>
478         <heading>Collision List</heading>
479         <query>SELECT ac.barcode FROM m_asset_copy_legacy ac WHERE ac.barcode LIKE 'x_%' ORDER BY 1 LIMIT 20</query>
480         <note>This is a shortlist of copy barcode collisions that maxes out at 20.  If there are more collisions we will need to run a custom report.</note>
481     </report>
482
483     <report>
484         <name>m_asset_barcode_collisions_shortlist</name>
485         <report_title>Copy Barcode Collisions (first 20)</report_title>
486         <tag>assets</tag>
487         <iteration>1</iteration>
488         <heading>Collision List</heading>
489         <query>SELECT ac.barcode FROM m_asset_copy ac WHERE ac.barcode LIKE 'x_%' ORDER BY 1 LIMIT 20</query>
490         <note>This is a shortlist of patron barcode collisions that maxes out at 20.  If there are more collisions we will need to run a custom report.</note>
491     </report>
492
493     <report>
494         <name>m_asset_barcode_collision_patterns</name>
495         <report_title>Common Copy Barcode Collision Patterns</report_title>
496         <tag>assets</tag>
497         <iteration>0</iteration>
498         <heading>Number of Barcodes Matching Pattern Greater than 10.Left 60% of Characters</heading>
499         <query>SELECT COUNT(ac.id), LEFT(ac.barcode,(ROUND(LENGTH(ac.barcode)*.6))::INT) FROM m_asset_copy_legacy ac WHERE barcode LIKE 'x_%' GROUP BY 2 HAVING COUNT(ac.id) > 10 ORDER BY 2</query>
500     </report>
501
502     <report>
503         <name>m_asset_barcode_collision_patterns</name>
504         <report_title>Common Copy Barcode Collision Patterns</report_title>
505         <tag>assets</tag>
506         <iteration>1</iteration>
507         <heading>Number of Barcodes Matching Pattern Greater than 10.Left 60% of Characters</heading>
508         <query>SELECT COUNT(ac.id), LEFT(ac.barcode,(ROUND(LENGTH(ac.barcode)*.6))::INT) FROM m_asset_copy ac WHERE barcode LIKE 'x_%' GROUP BY 2 HAVING COUNT(ac.id) > 10 ORDER BY 2</query>
509     </report>
510
511     <report>
512          <name>m_asset_stat_cats</name>
513         <report_title>Copy Statistical Categories</report_title>
514         <tag>assets</tag>
515         <iteration>0</iteration>
516         <heading>Stat Cat Count.Library.Statistical Category</heading>
517         <query>SELECT COUNT(ac_sc.id), aou.name, ac_sc.name FROM m_asset_stat_cat_legacy ac_sc JOIN actor.org_unit aou ON aou.id = ac_sc.owner GROUP BY 2,3 ORDER BY 2,3</query>
518     </report>
519
520     <report>
521          <name>m_asset_stat_cats</name>
522         <report_title>Copy Statistical Categories</report_title>
523         <tag>assets</tag>
524         <iteration>1</iteration>
525         <heading>Stat Cat Count.Library.Statistical Category</heading>
526         <query>SELECT COUNT(ac_sc.id), aou.name, ac_sc.name FROM m_asset_stat_cat ac_sc JOIN actor.org_unit aou ON aou.id = ac_sc.owner GROUP BY 2,3 ORDER BY 2,3</query>
527     </report>
528
529     <report>
530         <name>m_asset_stat_cat_entries</name>
531         <report_title>Copy Stat Cat User Entries</report_title>
532         <tag>assets</tag>
533         <iteration>0</iteration>
534         <heading>Copy Stat Count.Library.Statistical Category</heading>
535         <query>SELECT COUNT(map.id), aou.name, ac_sc.name FROM m_asset_stat_cat_entry_copy_map_legacy map JOIN m_asset_stat_cat_legacy ac_sc ON ac_sc.id = map.stat_cat JOIN actor.org_unit aou ON aou.id = ac_sc.owner GROUP BY 2,3 ORDER BY 2,3</query>
536     </report>
537
538     <report>
539         <name>m_asset_stat_cat_entries</name>
540         <report_title>Copy Stat Cat User Entries</report_title>
541         <tag>assets</tag>
542         <iteration>1</iteration>
543         <heading>Copy Stat Count.Library.Statistical Category</heading>
544         <query>SELECT COUNT(map.id), aou.name, ac_sc.name FROM m_asset_stat_cat_entry_copy_map map JOIN m_asset_stat_cat ac_sc ON ac_sc.id = map.stat_cat JOIN actor.org_unit aou ON aou.
545 id = ac_sc.owner GROUP BY 2,3 ORDER BY 2,3</query>
546     </report>
547
548     <report>
549          <name>m_asset_copy_tags</name>
550         <report_title>Copy Tags</report_title>
551         <tag>assets</tag>
552         <iteration>0</iteration>
553         <heading>Tag Count.Copy Tag Type.Copy Tag Label.Staff Note.Public</heading>
554         <query>SELECT COUNT(map.id), tag.tag_type, tag.label, tag.staff_note, tag.pub FROM m_asset_copy_tag tag JOIN m_asset_copy_tag_copy_map map ON map.tag = tag.id GROUP BY 2,3,4,5 ORDER BY 2,3</query>
555     </report>
556
557     <report>
558          <name>m_asset_copy_alerts</name>
559         <report_title>Copy Alerts</report_title>
560         <tag>assets</tag>
561         <iteration>0</iteration>
562         <heading>Alert Count.Alert Type</heading>
563                 <query>SELECT COUNT(*), cat.name FROM m_asset_copy_alert aca JOIN config.copy_alert_type cat ON cat.id = aca.alert_type GROUP BY 2</query>
564     </report>
565
566     <!-- MONEY REPORTS -->
567
568     <report>
569         <name>m_money_billing_voided</name>
570         <report_title>Bills Voided And Not</report_title>
571         <tag>money</tag>
572         <iteration>0</iteration>
573         <heading>Count.Voided.Sum.Migrated</heading>
574         <query>SELECT COUNT(a.id), a.voided::TEXT, SUM(a.amount), a.x_migrate::TEXT FROM m_money_billing_legacy a GROUP BY 2, 4 ORDER BY 2, 4</query>
575     </report>
576
577     <report>
578         <name>m_money_billing_voided</name>
579         <report_title>Bills Voided And Not</report_title>
580         <tag>money</tag>
581         <iteration>1</iteration>
582         <heading>Count.Voided.Sum</heading>
583         <query>SELECT COUNT(a.id), a.voided::TEXT, SUM(a.amount) FROM m_money_billing a GROUP BY 2 ORDER BY 2, 3</query>
584     </report>
585
586     <report>
587         <name>m_money_billing_by_type</name>
588         <report_title>Bills by Type</report_title>
589         <tag>money</tag>
590         <iteration>0</iteration>
591         <heading>Count.Billing Type.Migrated</heading>
592         <query>SELECT COUNT(a.id), a.billing_type, a.x_migrate::TEXT FROM m_money_billing_legacy a GROUP BY 2, 3 ORDER BY 2, 3</query>
593     </report>
594
595     <report>
596         <name>m_money_billing_by_type</name>
597         <report_title>Bills by Type</report_title>
598         <tag>money</tag>
599         <iteration>1</iteration>
600         <heading>Count.Billing Type</heading>
601         <query>SELECT COUNT(a.id), a.billing_type FROM m_money_billing a GROUP BY 2 ORDER BY 2</query>
602     </report>
603
604     <report>
605         <name>m_money_cash_payment</name>
606         <report_title>Cash Payments</report_title>
607         <tag>money</tag>
608         <iteration>0</iteration>
609         <heading>Count.Voided.Sum.Migrated</heading>
610         <query>SELECT COUNT(a.id), a.voided::TEXT, SUM(a.amount), a.x_migrate::TEXT FROM m_money_cash_payment_legacy a GROUP BY 2, 4 ORDER BY 2, 4</query>
611     </report>
612
613     <report>
614         <name>m_money_cash_payment</name>
615         <report_title>Cash Payments</report_title>
616         <tag>money</tag>
617         <iteration>1</iteration>
618         <heading>Count.Voided.Sum</heading>
619         <query>SELECT COUNT(a.id), a.voided::TEXT, SUM(a.amount) FROM m_money_cash_payment a GROUP BY 2 ORDER BY 2</query>
620     </report>
621
622     <report>
623         <name>m_money_check_payment</name>
624         <report_title>Check Payments</report_title>
625         <tag>money</tag>
626         <iteration>0</iteration>
627         <heading>Count.Voided.Sum.Migrated</heading>
628         <query>SELECT COUNT(a.id), a.voided::TEXT, SUM(a.amount), a.x_migrate::TEXT FROM m_money_check_payment_legacy a GROUP BY 2, 4 ORDER BY 2, 4</query>
629     </report>
630
631     <report>
632         <name>m_money_forgive_payment</name>
633         <report_title>Forgive Payments</report_title>
634         <tag>money</tag>
635         <iteration>0</iteration>
636         <heading>Count.Voided.Sum.Migrated</heading>
637         <query>SELECT COUNT(a.id), a.voided::TEXT, SUM(a.amount), a.x_migrate::TEXT FROM m_money_forgive_payment_legacy a GROUP BY 2, 4 ORDER BY 2, 4</query>
638     </report>
639
640     <report>
641         <name>m_money_forgive_payment</name>
642         <report_title>Forgive Payments</report_title>
643         <tag>money</tag>
644         <iteration>1</iteration>
645         <heading>Count.Voided.Sum</heading>
646         <query>SELECT COUNT(a.id), a.voided::TEXT, SUM(a.amount) FROM m_money_forgive_paymen a GROUP BY 2 ORDER BY 2</query>
647     </report>
648
649     <report>
650         <name>m_money_goods_payment</name>
651         <report_title>Goods Payments</report_title>
652         <tag>money</tag>
653         <iteration>0</iteration>
654         <heading>Count.Voided.Sum.Migrated</heading>
655         <query>SELECT COUNT(a.id), a.voided::TEXT, SUM(a.amount), a.x_migrate::TEXT FROM m_money_goods_payment_legacy a GROUP BY 2, 4 ORDER BY 2, 4</query>
656     </report>
657
658     <report>
659         <name>m_money_work_payment</name>
660         <report_title>Work Payments</report_title>
661         <tag>money</tag>
662         <iteration>0</iteration>
663         <heading>Count.Voided.Sum.Migrated</heading>
664         <query>SELECT COUNT(a.id), a.voided::TEXT, SUM(a.amount), a.x_migrate::TEXT FROM m_money_work_payment_legacy a GROUP BY 2, 4 ORDER BY 2, 4</query>
665     </report>
666
667     <report>
668         <name>m_money_credit_card_payment</name>
669         <report_title>Credit Card Payments</report_title>
670         <tag>money</tag>
671         <iteration>0</iteration>
672         <heading>Count.Voided.Sum.Migrated</heading>
673         <query>SELECT COUNT(a.id), a.voided::TEXT, SUM(a.amount), a.x_migrate::TEXT FROM m_money_credit_card_payment_legacy a GROUP BY 2, 4 ORDER BY 2, 4</query>
674     </report>
675
676     <report>
677         <name>m_money_credit_payment</name>
678         <report_title>Credit Payments</report_title>
679         <tag>money</tag>
680         <iteration>0</iteration>
681         <heading>Count.Voided.Sum.Migrated</heading>
682         <query>SELECT COUNT(a.id), a.voided::TEXT, SUM(a.amount), a.x_migrate::TEXT FROM m_money_credit_payment_legacy a GROUP BY 2, 4 ORDER BY 2, 4</query>
683     </report>
684
685
686     <!-- BIBS REPORTS -->
687
688     <report>
689         <name>bibs_loaded</name>
690         <report_title>Loaded Bibliographic Records</report_title>
691         <tag>bibs</tag>
692         <iteration>0</iteration>
693         <heading>Count</heading>
694         <query>SELECT COUNT(bre.id) FROM m_biblio_record_entry_legacy bre WHERE id IN (SELECT id FROM biblio.record_entry) ORDER BY 1</query>
695     </report>
696
697     <report>
698         <name>bibs_loaded</name>
699         <report_title>Loaded Bibliographic Records</report_title>
700         <tag>bibs</tag>
701         <iteration>1</iteration>
702         <heading>Count</heading>
703         <query>SELECT COUNT(bre.id) FROM m_biblio_record_entry bre WHERE id IN (SELECT id FROM biblio.record_entry) ORDER BY 1</query>
704     </report>
705
706     <report>
707         <name>bibswovolumes</name>
708         <report_title>Bibliographic Records Without Volumes</report_title>
709         <tag>bibs</tag>
710         <iteration>0</iteration>
711         <heading>Count</heading>
712         <query>SELECT COUNT(id) FROM m_biblio_record_entry where id NOT IN (SELECT DISTINCT record FROM m_asset_call_number)</query>
713                 <note>These records would not have been loaded.</note>
714     </report>
715
716     <report>
717         <name>bibswuri</name>
718         <report_title>Bibliographic Records With 856$9s</report_title>
719         <tag>bibs</tag>
720         <iteration>0</iteration>
721         <heading>Count</heading>
722         <query>SELECT COUNT(id) FROM m_biblio_record_entry where id IN (SELECT record FROM asset.call_number WHERE label ~* '##URI##')</query>
723     </report>
724
725         <report>
726                 <name>bibsff</name>
727                 <report_title>Bibliographic Records with Adjusted Fixed Fields</report_title>
728                 <tag>bibs</tag>
729                 <iteration>0</iteration>
730                 <heading>Count.Original Search Format.New Search Format</heading>
731                 <query>SELECT COUNT(*), ARRAY_TO_STRING(x_search_format,','), ARRAY_TO_STRING(x_after_search_format,',') FROM m_biblio_record_entry_legacy WHERE x_migrate AND x_after_search_format IS NOT NULL GROUP BY 2, 3 ORDER BY 3,2</query>
732         </report>
733
734     <report>
735         <name>bibs_notes</name>
736         <report_title>Bib Record Notes</report_title>
737         <tag>bibs</tag>
738         <iteration>0</iteration>
739         <heading>Count.Migrated</heading>
740         <query>SELECT COUNT(b.id), b.x_migrate::TEXT FROM m_biblio_record_note_legacy b GROUP BY 2</query>
741     </report>
742
743     <report>
744         <name>bibs_notes</name>
745         <report_title>Bib Record Notes</report_title>
746         <tag>bibs</tag>
747         <iteration>1</iteration>
748         <heading>Count</heading>
749         <query>SELECT COUNT(b.id) FROM m_biblio_record_note b</query>
750     </report>
751
752     <report>
753         <name>bibs_peers</name>
754         <report_title>Peer Bib Copies</report_title>
755         <tag>bibs</tag>
756         <iteration>0</iteration>
757         <heading>Count.Migrated</heading>
758         <query>SELECT COUNT(b.id), b.x_migrate::TEXT FROM m_biblio_peer_bib_copy_map_legacy b GROUP BY 2</query>
759     </report>
760
761     <report>
762         <name>bibs_peers</name>
763         <report_title>Peer Bib Copies</report_title>
764         <tag>bibs</tag>
765         <iteration>1</iteration>
766         <heading>Count</heading>
767         <query>SELECT COUNT(b.id) FROM m_biblio_peer_bib_copy_map b</query>
768     </report>
769
770     <report>
771         <name>bibs_parts</name>
772         <report_title>Monograph Parts</report_title>
773         <tag>bibs</tag>
774         <iteration>0</iteration>
775         <heading>Count.Migrated</heading>
776         <query>SELECT COUNT(b.id), b.x_migrate::TEXT FROM m_biblio_monograph_part_legacy b GROUP BY 2</query>
777     </report>
778
779     <report>
780         <name>bibs_parts</name>
781         <report_title>Monograph Parts</report_title>
782         <tag>bibs</tag>
783         <iteration>1</iteration>
784         <heading>Count</heading>
785         <query>SELECT COUNT(b.id) FROM m_biblio_monograph_part b</query>
786     </report>
787
788     <report>
789         <name>bib_merges</name>
790         <report_title>Bibliographic Merge Count</report_title>
791         <tag>bibs</tag>
792         <iteration>0</iteration>
793         <heading>Records Merged.Incumbent Records Merged Into</heading>
794         <query>SELECT SUM(array_length(records,1)), COUNT(*) FROM groups</query>
795     </report>
796
797     <report>
798         <name>bib_merges_searchformat</name>
799         <report_title>Bibliographic Merges By Search Format</report_title>
800         <tag>bibs</tag>
801         <iteration>0</iteration>
802         <heading>Count.Item Type</heading>
803         <query>DROP TABLE IF EXISTS temp_unnest; CREATE TABLE temp_unnest AS (SELECT UNNEST(records) FROM groups); SELECT COUNT(record), search_format_str FROM dedupe_batch WHERE record IN (SELECT * FROM temp_unnest) GROUP BY 2 ORDER BY 2</query>
804     </report>
805
806         <report>
807         <name>bibs_not_loaded</name>
808         <report_title>Bibliographic Records That Failed to Load</report_title>
809         <tag>bibs</tag>
810         <iteration>0</iteration>
811         <heading>Title.Author.Control Number</heading>
812         <query>SELECT LEFT(ARRAY_TO_STRING(oils_xpath( '//*[@tag="245"]/*[@code="a"]/text()', a.marc),''),50) AS "Title",
813                                 LEFT(ARRAY_TO_STRING(oils_xpath( '//*[@tag="100"]/*[@code="a"]/text()', a.marc),''),50) AS "Author",
814                                 ARRAY_TO_STRING(oils_xpath( '//*[@tag="001"]/text()', a.marc),'') AS "001"
815                                 FROM m_biblio_record_entry a LEFT JOIN biblio.record_entry b ON b.id = a.id WHERE b.id IS NULL AND a.x_migrate
816                 </query>
817     </report>
818
819
820     <!-- ACTORS REPORTS -->
821
822     <report>
823         <name>usrsbyorg</name>
824         <report_title>Patrons by Home Org</report_title>
825         <tag>actors</tag>
826         <iteration>0</iteration>
827         <heading>Count.Library.Deleted.Migrated</heading>
828         <query>SELECT COUNT(au.id), aou.name, au.deleted::TEXT, au.x_migrate::TEXT FROM m_actor_usr_legacy au JOIN actor.org_unit aou ON aou.id = au.home_ou GROUP BY 2, 3, 4 ORDER BY 2, 3, 4</query>
829     </report>
830
831     <report>
832         <name>usrsbypgt</name>
833         <report_title>Patrons by Permission Group</report_title>
834         <tag>actors</tag>
835         <iteration>0</iteration>
836         <heading>Count.Permission Group.Migrated</heading>
837         <query>SELECT COUNT(au.id), pgt.name, au.x_migrate::TEXT FROM m_actor_usr_legacy au JOIN permission.grp_tree pgt ON pgt.id = au.profile GROUP BY 2, 3 ORDER BY 2, 3</query>
838     </report>
839
840     <report>
841         <name>active_usrs</name>
842         <report_title>Patron by Active Status</report_title>
843         <tag>actors</tag>
844         <iteration>0</iteration>
845         <heading>Count of Users.Active.Migrated</heading>
846         <query>SELECT COUNT(id), active::TEXT, x_migrate::TEXT FROM m_actor_usr_legacy GROUP BY 2, 3</query>
847     </report>
848
849     <report>
850         <name>active_usrs</name>
851         <report_title>Patrons by Active Status</report_title>
852         <tag>actors</tag>
853         <iteration>1</iteration>
854         <heading>Count of Users.Active</heading>
855         <query>SELECT COUNT(id), active::TEXT FROM m_actor_usr GROUP BY 2</query>
856     </report>
857
858     <report>
859         <name>active_usr_barcodes</name>
860         <report_title>Patron Barcodes by Active Status</report_title>
861         <tag>actors</tag>
862         <iteration>0</iteration>
863         <heading>Count of Barcodes.Active.Migrated</heading>
864         <query>SELECT COUNT(id), active::TEXT, x_migrate::TEXT FROM m_actor_card_legacy GROUP BY 2, 3</query>
865     </report>
866
867     <report>
868         <name>active_usr_barcodes</name>
869         <report_title>Patron Barcodes by Active Status</report_title>
870         <tag>actors</tag>
871         <iteration>1</iteration>
872         <heading>Count of Barcodes.Active</heading>
873         <query>SELECT COUNT(id), active::TEXT FROM m_actor_card GROUP BY 2</query>
874     </report>
875
876     <!-- report>
877         <name>usr_barcode_lengths</name>
878         <report_title>Barcode Lengths by Library</report_title>
879         <tag>actors</tag>
880         <iteration>0</iteration>
881         <heading>Count of Barcode.Barcode Length.Library</heading>
882         <query>SELECT COUNT(acard.id), LENGTH(acard.barcode), aou.name FROM m_actor_card_legacy acard JOIN m_actor_usr_legacy au ON au.id = acard.usr JOIN actor.org_unit aou ON aou.id = au.home_ou WHERE acard.x_migrate = TRUE GROUP BY 2, 3 ORDER BY 3, 2</query>
883     </report -->
884
885     <!-- report>
886         <name>usr_barcode_lengths</name>
887         <report_title>Barcode Lengths by Library</report_title>
888         <tag>actors</tag>
889         <iteration>1</iteration>
890         <heading>Count of Barcode.Barcode Length.Library</heading>
891         <query>SELECT COUNT(acard.id), LENGTH(acard.barcode), aou.name FROM m_actor_card acard JOIN m_actor_usr au ON au.id = acard.usr JOIN actor.org_unit aou ON aou.id = au.home_ou GROUP BY 2, 3 ORDER BY 3, 2</query>
892     </report -->
893
894     <report>
895         <name>usr_barcode_patterns</name>
896         <report_title>Common Barcode Starting Patterns</report_title>
897         <tag>actors</tag>
898         <iteration>0</iteration>
899         <heading>Count of Barcodes (greater than 10).Left 60% of Characters</heading>
900         <query>SELECT COUNT(acard.id), LEFT(acard.barcode,(ROUND(LENGTH(acard.barcode)*.6))::INT) FROM m_actor_card_legacy acard WHERE acard.x_migrate = TRUE GROUP BY 2 HAVING COUNT(acard.id) > 10 ORDER BY 2</query>
901     </report>
902
903     <report>
904         <name>usr_barcode_patterns</name>
905         <report_title>Common Barcode Starting Patterns</report_title>
906         <tag>actors</tag>
907         <iteration>1</iteration>
908         <heading>Count of Barcodes (greater than 10).Left 60% of Characters</heading>
909         <query>SELECT COUNT(acard.id), LEFT(acard.barcode,(ROUND(LENGTH(acard.barcode)*.6))::INT) FROM m_actor_card acard GROUP BY 2 HAVING COUNT(acard.id) > 10 ORDER BY 2</query>
910     </report>
911  
912    <report>
913         <name>usr_barcode_collisions</name>
914         <report_title>Patron Barcode Collisions</report_title>
915         <tag>actors</tag>
916         <iteration>0</iteration>
917         <heading>Collision Count</heading>
918         <query>SELECT COUNT(acard.id) FROM m_actor_card_legacy acard WHERE barcode LIKE 'x_%' AND x_migrate = TRUE</query>
919     </report>
920
921     <report>
922         <name>usr_barcode_collisions</name>
923         <report_title>Patron Barcode Collisions</report_title>
924         <tag>actors</tag>
925         <iteration>1</iteration>
926         <heading>Collision Count</heading>
927         <query>SELECT COUNT(acard.id) FROM m_actor_card acard WHERE barcode LIKE 'x_%'</query>
928     </report>
929
930     <report>
931         <name>usr_barcode_collision_shortlist</name>
932         <report_title>Patron Barcode Collisions (first 20)</report_title>
933         <tag>actors</tag>
934         <iteration>0</iteration>
935         <heading>Collision List</heading>
936         <query>SELECT acard.barcode FROM m_actor_card_legacy acard WHERE acard.barcode LIKE 'x_' AND acard.x_migrate = TRUE ORDER BY 1 LIMIT 20</query>
937         <note>This is a shortlist of patron barcode collisions that maxes out at 20.  If there are more collisions we will need to run a custom report.  In some cases we may flag individual accounts to not migrate.</note>
938     </report>
939
940     <report>
941         <name>usr_barcode_collision_shortlist</name>
942         <report_title>Patron Barcode Collisions (first 20)</report_title>
943         <tag>actors</tag>
944         <iteration>1</iteration>
945         <heading>Collision List</heading>
946         <query>SELECT acard.barcode FROM m_actor_card acard WHERE acard.barcode LIKE 'x_%' ORDER BY 1 LIMIT 20</query>
947         <note>This is a shortlist of patron barcode collisions that maxes out at 20.  If there are more collisions we will need to run a custom report.  In some cases we may flag individual accounts to not migrate.</note>
948     </report>
949
950     <report>
951         <name>usr_barcode_collision_patterns</name>
952         <report_title>Common Patron Barcode Collision Patterns</report_title> a.x_migrate
953         <tag>actors</tag>
954         <iteration>0</iteration>
955         <heading>Number of Barcodes Matching Pattern Greater than 10.Left 60% of Characters</heading>
956         <query>SELECT COUNT(acard.id), LEFT(acard.barcode,(ROUND(LENGTH(acard.barcode)*.6))::INT) FROM m_actor_card_legacy acard WHERE (acard.barcode ~* 'collision' OR acard.barcode ~* '^x_') AND acard.x_migrate = TRUE GROUP BY 2 HAVING COUNT(acard.id) > 10 ORDER BY 2</query>
957     </report>
958
959     <report>
960         <name>usr_barcode_collision_patterns</name>
961         <report_title>Common Patron Barcode Collision Patterns</report_title> a.x_migrate
962         <tag>actors</tag>
963         <iteration>1</iteration>
964         <heading>Number of Barcodes Matching Pattern Greater than 10.Left 60% of Characters</heading>
965         <query>SELECT COUNT(acard.id), LEFT(acard.barcode,(ROUND(LENGTH(acard.barcode)*.6))::INT) FROM m_actor_card acard WHERE (acard.barcode ~* 'collision' OR acard.barcode ~* '^x_') GROUP BY 2 HAVING COUNT(acard.id) > 10 ORDER BY 2</query>
966     </report>
967
968     <report>
969         <name>usr_addressses_status</name>
970         <report_title>Patron Addresses by Valid Status</report_title>
971         <tag>actors</tag>
972         <iteration>0</iteration>
973         <heading>Count.Valid.Migrated</heading>
974         <query>SELECT COUNT(aua.id), valid::TEXT, x_migrate::TEXT FROM m_actor_usr_address_legacy aua GROUP BY 2, 3</query>
975     </report>
976
977     <report>
978         <name>usr_addressses_status</name>
979         <report_title>Patron Addresses by Valid Status</report_title>
980         <tag>actors</tag>
981         <iteration>1</iteration>
982         <heading>Count.Valid</heading>
983         <query>SELECT COUNT(aua.id), valid::TEXT FROM m_actor_usr_address aua GROUP BY 2</query>
984     </report>
985
986     <report>
987         <name>usr_addresses_pending</name>
988         <report_title>Patron Addresses by Pending Status</report_title>
989         <tag>actors</tag>
990         <iteration>0</iteration>
991         <heading>Count of Addresses.Pending.Migrated</heading>
992         <query>SELECT COUNT(aua.id), pending::TEXT, x_migrate::TEXT FROM m_actor_usr_address_legacy aua GROUP BY 2, 3</query>
993     </report>
994
995     <report>
996         <name>usr_addresses_pending</name>
997         <report_title>Patron Addresses by Pending Status</report_title>
998         <tag>actors</tag>
999         <iteration>1</iteration>
1000         <heading>Count of Addresses.Pending</heading>
1001         <query>SELECT COUNT(aua.id), pending::TEXT FROM m_actor_usr_address aua GROUP BY 2</query>
1002     </report>
1003
1004     <report>
1005         <name>usr_messages</name>
1006         <report_title>Patron Messages</report_title>
1007         <tag>actors</tag>
1008         <iteration>0</iteration>
1009         <heading>Count.Deleted.Migrated</heading>
1010         <query>SELECT COUNT(aum.id), deleted::TEXT, x_migrate::TEXT FROM m_actor_usr_message_legacy aum GROUP BY 2, 3</query>
1011     </report>
1012
1013     <report>
1014         <name>usr_messages</name>
1015         <report_title>Patron Messages</report_title>
1016         <tag>actors</tag>
1017         <iteration>1</iteration>
1018         <heading>Count.Deleted</heading>
1019         <query>SELECT COUNT(aum.id), deleted::TEXT FROM m_actor_usr_message_legacy aum GROUP BY 2</query>
1020     </report>
1021
1022     <report>
1023         <name>usr_notes</name>
1024         <report_title>Patron Notes</report_title>
1025         <tag>actors</tag>
1026         <iteration>0</iteration>
1027         <heading>Count.Public.Migrated</heading>
1028         <query>SELECT COUNT(aun.id), pub::TEXT, x_migrate::TEXT FROM m_actor_usr_note_legacy aun GROUP BY 2, 3</query>
1029     </report>
1030
1031     <report>
1032         <name>usr_notes</name>
1033         <report_title>Patron Notes</report_title>
1034         <tag>actors</tag>
1035         <iteration>1</iteration>
1036         <heading>Count.Public</heading>
1037         <query>SELECT COUNT(aun.id), pub::TEXT FROM m_actor_usr_note aun GROUP BY 2</query>
1038     </report>
1039
1040     <report>
1041          <name>usr_stat_cats</name>
1042         <report_title>Patron Statistical Categories</report_title>
1043         <tag>actors</tag>
1044         <iteration>0</iteration>
1045         <heading>Stat Cat Count.Library.Statistical Category.Migrated</heading>
1046         <query>SELECT COUNT(au_sc.id), aou.name, au_sc.name, au_sc.x_migrate::TEXT FROM m_actor_stat_cat_legacy au_sc JOIN actor.org_unit aou ON aou.id = au_sc.owner GROUP BY 2, 3, 4 ORDER BY 2, 3, 4</query>
1047     </report>
1048
1049     <report>
1050          <name>usr_stat_cats</name>
1051         <report_title>Patron Statistical Categories</report_title>
1052         <tag>actors</tag>
1053         <iteration>1</iteration>
1054         <heading>Stat Cat Count.Library.Statistical Category</heading>
1055         <query>SELECT COUNT(au_sc.id), aou.name, au_sc.name FROM m_actor_stat_cat au_sc JOIN actor.org_unit aou ON aou.id = au_sc.owner GROUP BY 2, 3 ORDER BY 2, 3</query>
1056     </report>
1057
1058     <report>
1059         <name>usr_stat_cat_entries</name>
1060         <report_title>Patron Stat Cat User Entries</report_title>
1061         <tag>actors</tag>
1062         <iteration>0</iteration>
1063         <heading>Patron Stat Count.Library.Statistical Category.Migrated</heading>
1064         <query>SELECT COUNT(map.id), aou.name, au_sc.name, map.x_migrate::TEXT FROM m_actor_stat_cat_entry_usr_map_legacy map JOIN m_actor_stat_cat_legacy au_sc ON au_sc.id = map.stat_cat JOIN actor.org_unit aou ON aou.id = au_sc.owner GROUP BY 2, 3, 4 ORDER BY 2,3, 4</query>
1065     </report>
1066
1067     <report>
1068         <name>usr_stat_cat_entries</name>
1069         <report_title>Patron Stat Cat User Entries</report_title>
1070         <tag>actors</tag>
1071         <iteration>1</iteration>
1072         <heading>Patron Stat Count.Library.Statistical Category</heading>
1073         <query>SELECT COUNT(map.id), aou.name, au_sc.name FROM m_actor_stat_cat_entry_usr_map map JOIN m_actor_stat_cat au_sc ON au_sc.id = map.stat_cat JOIN actor.org_unit aou ON aou.id = au_sc.owner GROUP BY 2, 3 ORDER BY 2,3</query>
1074     </report>
1075
1076     <report>
1077         <name>usr_thresholds</name>
1078         <report_title>Patron Thresholds</report_title>
1079         <tag>actors</tag>
1080         <iteration>0</iteration>
1081         <heading>Pateron Group.Org Unit.Penalty.Threshold</heading>
1082         <query>SELECT pgt.name, aou.shortname, sp.name, p.threshold FROM permission_grp_penalty_threshold p 
1083                 JOIN actor.org_unit aou ON aou.id = p.org_unit JOIN permission.grp_tree pgt ON pgt.id = p.grp JOIN config.standing_penalty sp ON sp.id = p.penalty
1084                 ORDER BY 2, 1, 3</query>
1085     </report>
1086
1087     <report>
1088         <name>usr_settings</name>
1089         <report_title>Patron Settings</report_title>
1090         <tag>actors</tag>
1091         <iteration>0</iteration>
1092         <heading>Count.Setting.Value</heading>
1093         <query>SELECT COUNT(*), name, 'User''s Phone' FROM m_actor_usr_setting WHERE name IN ('opac.default_phone') GROUP BY 2, 3 
1094                         UNION ALL SELECT COUNT(*), name, value FROM m_actor_usr_setting WHERE name IN ('opac.hold_notify') GROUP BY 2, 3 
1095                         UNION ALL SELECT COUNT(*), a.name, aou.shortname FROM m_actor_usr_setting a JOIN actor.org_unit aou ON aou.id = REPLACE(a.value,'"','')::INTEGER 
1096                                 WHERE a.name IN ('opac.default_pickup_location','opac.default_search_location') GROUP BY 2, 3 ORDER BY 2, 3;</query>
1097     </report>
1098
1099     <!-- ACQUISITIONS REPORTS -->
1100     <report>
1101         <name>fund_count</name>
1102         <iteration>0</iteration>
1103         <tag>acq</tag>
1104         <report_title>Migrated Funds</report_title>
1105         <heading>Number of Funds.Migrated</heading>
1106         <query>SELECT COUNT(id), x_migrate::TEXT FROM m_acq_fund_legacy GROUP BY 2;</query>
1107     </report>
1108
1109     <report>                                                                        
1110         <name>fund_count</name>
1111         <iteration>1</iteration>
1112         <tag>acq</tag>
1113         <report_title>Migrated Funds</report_title>
1114         <heading>Number of Funds</heading>
1115         <query>SELECT COUNT(id) FROM m_acq_fund;</query>
1116     </report>
1117
1118     <report>
1119         <name>invoice_count</name>
1120         <iteration>0</iteration>
1121         <tag>acq</tag>
1122         <report_title>Migrated Invoices</report_title>
1123         <heading>Number of Invoices.Migrated</heading>
1124         <query>SELECT COUNT(id), x_migrate::TEXT FROM m_acq_invoice_legacy GROUP BY 2;</query>
1125     </report>
1126
1127     <report>
1128         <name>invoice_count</name>
1129         <iteration>1</iteration>
1130         <tag>acq</tag>
1131         <report_title>Migrated Invoices</report_title>
1132         <heading>Number of Funds</heading>
1133         <query>SELECT COUNT(id) FROM m_acq_invoice;</query>
1134     </report>    
1135
1136     <!-- SERIALS REPORTS -->
1137     <report>
1138         <name>serials_mfhd_count</name>
1139         <tag>serials</tag>
1140         <iteration>0</iteration>
1141         <report_title>Migrated Serial MFHDs</report_title>
1142         <heading>Number of MFHDs</heading>
1143         <query>SELECT COUNT(id) FROM m_serial_record_entry</query>
1144     </report>
1145
1146     <!-- DEDUPE REPORTS -->
1147
1148     <asset>
1149         <name>dedupe_explain</name>
1150         <tag>dedupe</tag>
1151         <file>dedupe_process.asciidoc</file> 
1152     </asset>
1153
1154     <report>
1155         <name>dedupe_bib_groups</name>
1156         <tag>dedupe</tag>
1157         <iteration>0</iteration>
1158         <report_title>Scoring and Bib Record Groups</report_title>
1159         <heading>Count.Bib Record Groups</heading>
1160         <query>SELECT COUNT(id), 'Total Bibs Being Evaluated' FROM biblio.record_entry WHERE deleted IS FALSE AND id IN (SELECT eg::BIGINT FROM bib_id_map)
1161           UNION ALL SELECT (COUNT(DISTINCT incoming_bib)), 'Incoming Bibs With Matches Found' FROM bib_matches
1162           UNION ALL SELECT (COUNT(bre.id) - (SELECT COUNT(DISTINCT incoming_bib) FROM bib_matches)), 'Incoming Bibs With No Match' 
1163                 FROM biblio.record_entry bre WHERE bre.deleted IS FALSE AND bre.id IN (SELECT eg::BIGINT FROM bib_id_map)
1164           UNION ALL SELECT COUNT(DISTINCT incoming_bib), 'Incoming Bibs Being Merged into Incumbent' FROM bib_matches WHERE incumbent_bib_score &gt;= incoming_bib_score
1165           UNION ALL SELECT COUNT(id), 'Incumbent Bibs With Higher Scores to Incoming' FROM bib_matches WHERE incumbent_bib_score &gt; incoming_bib_score
1166           UNION ALL SELECT COUNT(id), 'Incumbent Bibs With Equal Scores to Incoming' FROM bib_matches WHERE incumbent_bib_score = incoming_bib_score
1167           UNION ALL SELECT COUNT(id), 'Incumbent Bibs  With Lower Scores to Incoming' FROM bib_matches WHERE incumbent_bib_score &lt; incoming_bib_score
1168           ;</query>
1169     </report>
1170
1171     <report>
1172         <name>dedupe_format_count</name>
1173         <tag>dedupe</tag>
1174         <iteration>0</iteration>
1175         <report_title>Count of Items Matching By Format</report_title>
1176         <heading>Count.Format(s)</heading>
1177         <query>SELECT COUNT(id), search_formats FROM bib_matches GROUP BY 2 ORDER BY 2;</query>
1178     </report>
1179     
1180     <report>
1181         <name>dedupe_score_ranges</name>
1182         <tag>dedupe</tag>
1183         <iteration>0</iteration>
1184         <report_title>Count of Items Matching By Format</report_title>
1185         <heading>Lowest Record Score.Largest Record Score.Record Set</heading>
1186         <query>SELECT MIN(incumbent_bib_score), MAX(incumbent_bib_score), 'Incumbent Records' FROM bib_matches 
1187             UNION ALL SELECT MIN(incoming_bib_score), MAX(incoming_bib_score), 'Incoming Records' FROM bib_matches ;
1188         </query>
1189     </report>
1190     
1191     
1192     <report>
1193         <name>dedupe_sample_set</name>
1194         <tag>dedupe</tag>
1195         <iteration>0</iteration>
1196         <report_title>Sample of 20 Matching Dedupe Record Sets</report_title>
1197         <heading>Bib Being Merged Into.Bib Being Merged</heading>
1198         <query>SELECT incumbent_bib, incoming_bib FROM bib_matches WHERE incumbent_bib_score &gt;= incoming_bib_score LIMIT 20 ;
1199         </query>
1200     </report>
1201
1202     <!-- NOTICES REPORTS -->
1203
1204     <report>
1205         <name>notices_overview</name>
1206         <tag>notices</tag>
1207         <iteration>0</iteration>
1208         <report_title>Action Triggers Setup for Notices</report_title>
1209         <heading>ID.Active.Owner.Name</heading>
1210         <query>SELECT ed.id, ed.active, aou.shortname, ed.name
1211             FROM m_action_trigger.event_definition ed 
1212             JOIN actor.org_unit aou ON aou.id = ed.owner 
1213             WHERE ed.owner IN (SELECT DISTINCT home_ou FROM m_actor_usr)
1214             OR ed.owner IN (SELECT DISTINCT parent_ou FROM actor.org_unit WHERE id in (SELECT DISTINCT home_ou FROM m_actor_usr));
1215         </query>
1216     </report>
1217
1218     <report>
1219         <name>notices_count</name>
1220         <tag>notices</tag>
1221         <iteration>0</iteration>
1222         <report_title>Count of Notices Run with State</report_title>
1223         <heading>Count of Notices.State.ID.Owner.Name</heading>
1224         <query>SELECT COUNT(ate.id), ate.state, ed.id, aou.shortname, ed.name 
1225             FROM m_action_trigger.event_definition ed 
1226             JOIN actor.org_unit aou ON aou.id = ed.owner 
1227             JOIN m_action_trigger.event ate ON ate.event_def = ed.id 
1228             WHERE ed.owner IN (SELECT DISTINCT home_ou FROM m_actor_usr)
1229             OR ed.owner IN (SELECT DISTINCT parent_ou FROM actor.org_unit WHERE id in (SELECT DISTINCT home_ou FROM m_actor_usr))
1230             GROUP BY 2,3,4;
1231         </query>
1232     </report>
1233
1234
1235 </reports_file>
1236