Advertisement
roganhamby

Verbose Circ Matrix Report

May 23rd, 2014
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- really verbose alternative for getting the rules for in-db holds rules
  2. -- rather than just select * config.hold_matrix_matchpoint
  3. -- almost a necessity for a consortium with varying rules or any library
  4. -- with intricate polices because in-db holds policies are much easier to
  5. -- handle via SQL than through the staff client
  6. -- script has IDs for admins and look ups to names for easy reference
  7. -- tested on 2.1 and 2.4
  8. -- updated to include the circ limits information on 2.4.4 2013-12-19
  9. -- this tracks circ limits information for circ limits only not copy locations or MARC attributes
  10. -- (c) Rogan Hamby, 2013, roganhamby.com
  11. -- Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License
  12.  
  13.  
  14. SELECT cmm.id AS "circ matrix match id", cmm.is_renewal, org.shortname AS "org unit", tree.NAME AS "group", cmm.circ_modifier, cmm.circulate,
  15. cmm.active as "circ matrix active", cmm.marc_type, cmm.marc_form, cmm.marc_vr_format, cmm.ref_flag, cmm.usr_age_lower_bound, cmm.usr_age_upper_bound,
  16. cmm.juvenile_flag, cmm.script_test, cmm.hard_due_date, cmm.total_copy_hold_ratio, cmm.available_copy_hold_ratio, cmm.marc_bib_level,
  17. cmm_copy_circ.shortname as "cmm copy circ lib", cmm_copy_own.shortname as "cmm copy owning lib", cmm.renewals as "cmm renewals",
  18. cmm.user_home_ou as "cmm user home org unit", cmm.grace_period as "cmm grace period", cmm.item_age, aclx.name as "cmm copy location",
  19. duration.NAME AS "duration", duration.id AS "duration id", recurring.NAME AS "recurring", recurring.id AS "recurring id",
  20. maxfine.NAME AS "maxfine", maxfine.id AS "maxfine id", lsm.id AS "limit set map id", lsm.fallthrough AS "limit set map fallthrough",
  21. lsm.active AS "limit set map active", cls.id AS "circ limit id", cls.items_out AS "items out", limsetorg.shortname AS "limit set owning lib",
  22. cls.depth AS "limit set depth", cls.NAME AS "circ limit name", cls.global AS "circ limit global", cls.description AS "circ limit description",
  23. cls_circmod.id AS "cls_circmod id", cls_circmod.circ_mod AS "cls_circmod", cls_copyloc.id AS "cls_copyloc id", acl.NAME "copy location",
  24. cls_groupmap.id AS "cls group map", cls_groupmap.check_only AS "cls group check only",
  25. cls_group.id AS "clsgroup id", cls_group.NAME AS "clsgroup name", cls_group.description AS "clsgroup description"
  26. FROM config.circ_matrix_matchpoint cmm
  27. JOIN actor.org_unit org ON org.id = cmm.org_unit
  28. LEFT JOIN actor.org_unit cmm_copy_circ ON cmm_copy_circ.id = cmm.copy_circ_lib
  29. LEFT JOIN actor.org_unit cmm_copy_own ON cmm_copy_own.id = cmm.copy_owning_lib
  30. LEFT JOIN config.circ_matrix_limit_set_map lsm ON lsm.matchpoint = cmm.id
  31. LEFT JOIN actor.org_unit cmm_user_home on cmm_user_home.id = cmm.user_home_ou
  32. LEFT JOIN config.circ_limit_set cls ON cls.id = lsm.limit_set
  33. LEFT JOIN asset.copy_location aclx on aclx.id = cmm.copy_location
  34. JOIN permission.grp_tree tree ON tree.id = cmm.grp
  35. JOIN config.rule_circ_duration duration ON duration.id = cmm.duration_rule
  36. JOIN config.rule_max_fine maxfine ON maxfine.id = cmm.max_fine_rule
  37. JOIN config.rule_recurring_fine recurring ON recurring.id = cmm.recurring_fine_rule
  38. LEFT JOIN actor.org_unit limsetorg ON limsetorg.id = cls.owning_lib
  39. LEFT JOIN config.circ_limit_set_circ_mod_map cls_circmod ON cls_circmod.limit_set = cls.id
  40. LEFT JOIN config.circ_limit_set_copy_loc_map cls_copyloc ON cls_copyloc.limit_set = cls.id
  41. LEFT JOIN config.circ_limit_set_group_map cls_groupmap ON cls_groupmap.limit_set = cls.id
  42. LEFT JOIN config.circ_limit_group cls_group ON cls_group.id = cls_groupmap.limit_group
  43. LEFT JOIN asset.copy_location acl ON acl.id = cls_copyloc.copy_loc
  44. ;
  45.  
  46. -- where org.id in (160,165,164,163,161,162) ;
  47.  
  48. -- with thresholds
  49. -- could clean it up more with group bys but it gets changed so much for different things it's easier to do in the spreadsheet
  50.  
  51. SELECT cmm.id AS "circ matrix match id", cmm.is_renewal, org.shortname AS "org unit", tree.NAME AS "group", cmm.circ_modifier, cmm.circulate,
  52. cmm.active AS "circ matrix active", cmm.marc_type, cmm.marc_form, cmm.marc_vr_format, cmm.ref_flag, cmm.usr_age_lower_bound, cmm.usr_age_upper_bound,
  53. cmm.juvenile_flag, cmm.script_test, cmm.hard_due_date, cmm.total_copy_hold_ratio, cmm.available_copy_hold_ratio, cmm.marc_bib_level,
  54. cmm_copy_circ.shortname AS "cmm copy circ lib", cmm_copy_own.shortname AS "cmm copy owning lib", cmm.renewals AS "cmm renewals",
  55. cmm.user_home_ou AS "cmm user home org unit", cmm.grace_period AS "cmm grace period", cmm.item_age, aclx.NAME AS "cmm copy location",
  56. duration.NAME AS "duration", duration.id AS "duration id", recurring.NAME AS "recurring", recurring.id AS "recurring id",
  57. maxfine.NAME AS "maxfine", maxfine.id AS "maxfine id", lsm.id AS "limit set map id", lsm.fallthrough AS "limit set map fallthrough",
  58. lsm.active AS "limit set map active", cls.id AS "circ limit id", cls.items_out AS "items out", limsetorg.shortname AS "limit set owning lib",
  59. cls.depth AS "limit set depth", cls.NAME AS "circ limit name", cls.GLOBAL AS "circ limit global", cls.description AS "circ limit description",
  60. cls_circmod.id AS "cls_circmod id", cls_circmod.circ_mod AS "cls_circmod", cls_copyloc.id AS "cls_copyloc id", acl.NAME "copy location",
  61. cls_groupmap.id AS "cls group map", cls_groupmap.check_only AS "cls group check only",
  62. cls_group.id AS "clsgroup id", cls_group.NAME AS "clsgroup name", cls_group.description AS "clsgroup description",
  63. penalty_org.shortname, pgpt.threshold, csp.NAME AS "penalty name", csp.label AS "penalty description", csp.block_list, csp.org_depth, csp.staff_alert
  64. FROM config.circ_matrix_matchpoint cmm
  65. JOIN actor.org_unit org ON org.id = cmm.org_unit
  66. JOIN actor.org_unit org_parent ON org_parent.id = org.parent_ou
  67. LEFT JOIN actor.org_unit cmm_copy_circ ON cmm_copy_circ.id = cmm.copy_circ_lib
  68. LEFT JOIN actor.org_unit cmm_copy_own ON cmm_copy_own.id = cmm.copy_owning_lib
  69. LEFT JOIN config.circ_matrix_limit_set_map lsm ON lsm.matchpoint = cmm.id
  70. LEFT JOIN actor.org_unit cmm_user_home ON cmm_user_home.id = cmm.user_home_ou
  71. LEFT JOIN config.circ_limit_set cls ON cls.id = lsm.limit_set
  72. LEFT JOIN asset.copy_location aclx ON aclx.id = cmm.copy_location
  73. JOIN permission.grp_tree tree ON tree.id = cmm.grp
  74. JOIN config.rule_circ_duration duration ON duration.id = cmm.duration_rule
  75. JOIN config.rule_max_fine maxfine ON maxfine.id = cmm.max_fine_rule
  76. JOIN config.rule_recurring_fine recurring ON recurring.id = cmm.recurring_fine_rule
  77. LEFT JOIN actor.org_unit limsetorg ON limsetorg.id = cls.owning_lib
  78. LEFT JOIN config.circ_limit_set_circ_mod_map cls_circmod ON cls_circmod.limit_set = cls.id
  79. LEFT JOIN config.circ_limit_set_copy_loc_map cls_copyloc ON cls_copyloc.limit_set = cls.id
  80. LEFT JOIN config.circ_limit_set_group_map cls_groupmap ON cls_groupmap.limit_set = cls.id
  81. LEFT JOIN config.circ_limit_group cls_group ON cls_group.id = cls_groupmap.limit_group
  82. LEFT JOIN asset.copy_location acl ON acl.id = cls_copyloc.copy_loc
  83. LEFT JOIN permission.grp_penalty_threshold pgpt ON pgpt.grp = tree.id
  84. LEFT JOIN config.standing_penalty csp ON csp.id = pgpt.penalty
  85. LEFT JOIN actor.org_unit penalty_org ON penalty_org.id = pgpt.org_unit
  86. -- where (pgpt.org_unit = org.id or pgpt.org_unit = org_parent.id)
  87. ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement