Advertisement
roganhamby

Extend Reporter - Weeding

May 4th, 2015
334
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.03 KB | None | 0 0
  1. -- for /openils/var/web/reports/fm_IDL.xml & /openils/conf
  2.  
  3. <class id="erw" controller="openils.cstore" oils_obj:fieldmapper="extend_reporter::weeding" oils_persist:tablename="extend_reporter.weeding" reporter:core="true" reporter:label="Weeding">
  4. <fields>
  5. <field reporter:label="Number of Circs" name="num_of_circs" reporter:datatype="int"/>
  6. <field reporter:label="Barcode" name="barcode" reporter:datatype="text"/>
  7. <field reporter:label="Shelving Location" name="shelving_location" reporter:datatype="text"/>
  8. <field reporter:label="Call Number" name="call_number" reporter:datatype="text"/>
  9. <field reporter:label="Title" name="title" reporter:datatype="text"/>
  10. <field reporter:label="Library" name="library" reporter:datatype="text"/>
  11. <field reporter:label="Last Circulation" name="last_circulation" reporter:datatype="timestamp"/>
  12. <field reporter:label="Item Create Date" name="create_date" reporter:datatype="timestamp"/>
  13. </fields>
  14. </class>
  15.  
  16.  
  17. drop table if exists extend_reporter.weeding;
  18.  
  19. create table extend_reporter.weeding as
  20. SELECT COUNT(acirc.id) as "num_of_circs", ac.barcode AS "barcode", acl.NAME AS "shelving_location",
  21. acn.label AS "call_number", msr.title, child.shortname as library, MAX(acirc.xact_start) AS "last_circulation", ac.create_date
  22. FROM asset.COPY ac
  23. JOIN asset.copy_location acl ON ac.LOCATION = acl.id
  24. LEFT JOIN ACTION.circulation acirc ON acirc.target_copy = ac.id
  25. JOIN asset.call_number acn ON acn.id = ac.call_number
  26. JOIN reporter.materialized_simple_record msr ON msr.id = acn.record
  27. JOIN actor.org_unit child ON child.id = ac.circ_lib
  28. WHERE acirc.xact_start IS NULL
  29. AND date(ac.create_date) <= NOW() - INTERVAL '3 years'
  30. AND ac.deleted = FALSE
  31. AND ac.status = 0
  32. AND acl.circulate = TRUE
  33. GROUP BY 2, 3, 4, 5, 6, 8
  34. UNION ALL
  35. SELECT COUNT(acirc.id) as "num_of_circs", ac.barcode AS "barcode", acl.NAME AS "shelving_location",
  36. acn.label AS "call_number", msr.title, child.shortname as library, MAX(acirc.xact_start) AS "last_circulation", ac.create_date
  37. FROM asset.COPY ac
  38. JOIN asset.copy_location acl ON ac.LOCATION = acl.id
  39. LEFT JOIN ACTION.circulation acirc ON acirc.target_copy = ac.id
  40. JOIN asset.call_number acn ON acn.id = ac.call_number
  41. JOIN reporter.materialized_simple_record msr ON msr.id = acn.record
  42. JOIN actor.org_unit child ON child.id = ac.circ_lib
  43. WHERE date(ac.create_date) <= NOW() - INTERVAL '3 years'
  44. AND ac.deleted = FALSE
  45. AND ac.status = 0
  46. AND acl.circulate = TRUE
  47. GROUP BY 2, 3, 4, 5, 6, 8
  48. HAVING MAX(acirc.xact_start) < NOW() - INTERVAL '3 years'
  49. ;
  50.  
  51. select * from extend_reporter.weeding where library ilike 'YCL-RH' and shelving_location = 'Adult Fiction' and
  52. date(create_date) < now() - interval '5 years' and last_circulation is null;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement