Advertisement
roganhamby

Circ Matrix Report

Apr 18th, 2013
195
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.  
  15. SELECT ccm.id AS "Circ Matrix Matchpoint ID", ccm.active AS "Active", ccm.org_unit AS "Circ Org Unit", aou.shortname AS "Circ Short Org Unit Name",
  16. aou.parent_ou AS "Parent Org Unit", aou2.shortname "Parent Org Unit Short Name", pgt.id AS "Permission Group ID",
  17. pgt.NAME AS "Permission Group Name", ccm.circ_modifier AS "Circ Modifier", ccm.marc_type AS "MARC Type", ccm.marc_form AS "MARC Form",
  18. ccm.marc_vr_format AS "MARC Video Recording Format", ccm.ref_flag AS "Reference Boolean", ccm.is_renewal AS "Renewable Boolean",
  19. ccm.usr_age_lower_bound AS "Lower Age Bound", ccm.usr_age_upper_bound AS "Upper Age Bound", ccm.juvenile_flag AS "Juvenile",
  20. ccm.duration_rule AS "Duration Rule", dur.NAME AS "Duration Name", ccm.max_fine_rule AS "Max Fine Rule", maxf.NAME AS "Max Fine Name",
  21. ccm.recurring_fine_rule AS "Recurring Fine Rule", recur.NAME AS "Recurring Fine Name", ccm.total_copy_hold_ratio AS "Total Copy Hold Ratio",
  22. ccm.available_copy_hold_ratio AS "Available Copy Hold Ratio",
  23. ccm.hard_due_date AS "Hard Due Date ID", hdd.NAME AS "Hard Due Date Name",  
  24. ccm.copy_circ_lib AS "Copy Circ Lib ID", aou3.shortname AS "Copy Circ Lib Shortname",
  25. ccm.copy_owning_lib AS "Copy Owning Lib ID", aou4.shortname AS "Copy Owning Lib Shortname",
  26. ccm.renewals AS "Renewals",
  27. ccm.user_home_ou AS "User Home Lib ID", aou5.shortname AS "User Home Lib Shortname",
  28. ccm.grace_period AS "Grace Period", ccm.marc_bib_level AS "MARC Bib Level",
  29. lsm.id AS "Circ Limit Set Map ID", cls.owning_lib AS "Circ Limit Set Owning Lib", lsm.limit_set as "Circ Limit Set ID",
  30. aoucls.shortname AS "Circ Limit Set Owning Lib Name",
  31. cls.items_out "Circ Limit Set Items Out", cls.depth AS "Circ Limit Set Depth", cls.GLOBAL AS "Circ Limit Set Global",
  32. scmm.circ_mod AS "Circ Limit Set Circ Mod", scmm.id as "Circ Mod Map ID"
  33. FROM config.circ_matrix_matchpoint ccm
  34. LEFT JOIN actor.org_unit aou ON aou.id = ccm.org_unit
  35. LEFT JOIN actor.org_unit aou2 ON aou2.id = aou.parent_ou
  36. LEFT JOIN permission.grp_tree pgt ON pgt.id = ccm.grp
  37. LEFT JOIN config.rule_circ_duration dur ON dur.id = ccm.duration_rule
  38. LEFT JOIN config.rule_max_fine maxf ON maxf.id = ccm.max_fine_rule
  39. LEFT JOIN config.rule_recurring_fine recur ON recur.id = ccm.recurring_fine_rule
  40. LEFT JOIN config.hard_due_date hdd ON hdd.id = ccm.hard_due_date
  41. LEFT JOIN actor.org_unit aou3 ON aou3.id = ccm.copy_circ_lib
  42. LEFT JOIN actor.org_unit aou4 ON aou4.id = ccm.copy_owning_lib
  43. LEFT JOIN actor.org_unit aou5 ON aou5.id = ccm.user_home_ou
  44. LEFT JOIN config.circ_matrix_limit_set_map lsm ON lsm.matchpoint = ccm.id
  45. LEFT JOIN config.circ_limit_set cls ON cls.id = lsm.limit_set
  46. LEFT JOIN config.circ_limit_set_circ_mod_map scmm ON scmm.limit_set = cls.id
  47. LEFT JOIN actor.org_unit aoucls ON aoucls.id = cls.owning_lib
  48. ;
  49.  
  50.  
  51. -- shorter with circ
  52.  
  53. SELECT ccm.id AS "Circ Matrix Matchpoint ID", ccm.active AS "Active", ccm.circulate as "Circulate",
  54. ccm.org_unit AS "Circ Org Unit", aou.shortname AS "Circ Short Org Unit Name",
  55. aou.parent_ou AS "Parent Org Unit", aou2.shortname "Parent Org Unit Short Name", pgt.id AS "Permission Group ID",
  56. pgt.NAME AS "Permission Group Name", ccm.circ_modifier AS "Circ Modifier",
  57. ccm.duration_rule AS "Duration Rule", dur.NAME AS "Duration Name", ccm.max_fine_rule AS "Max Fine Rule", maxf.NAME AS "Max Fine Name",
  58. ccm.recurring_fine_rule AS "Recurring Fine Rule", recur.NAME AS "Recurring Fine Name",
  59. ccm.user_home_ou AS "User Home Lib ID", aou5.shortname AS "User Home Lib Shortname",
  60. lsm.id AS "Circ Limit Set Map ID", cls.owning_lib AS "Circ Limit Set Owning Lib", lsm.limit_set AS "Circ Limit Set ID",
  61. aoucls.shortname AS "Circ Limit Set Owning Lib Name",
  62. cls.items_out "Circ Limit Set Items Out", cls.depth AS "Circ Limit Set Depth", cls.GLOBAL AS "Circ Limit Set Global",
  63. scmm.circ_mod AS "Circ Limit Set Circ Mod", scmm.id AS "Circ Mod Map ID"
  64. FROM config.circ_matrix_matchpoint ccm
  65. LEFT JOIN actor.org_unit aou ON aou.id = ccm.org_unit
  66. LEFT JOIN actor.org_unit aou2 ON aou2.id = aou.parent_ou
  67. LEFT JOIN permission.grp_tree pgt ON pgt.id = ccm.grp
  68. LEFT JOIN config.rule_circ_duration dur ON dur.id = ccm.duration_rule
  69. LEFT JOIN config.rule_max_fine maxf ON maxf.id = ccm.max_fine_rule
  70. LEFT JOIN config.rule_recurring_fine recur ON recur.id = ccm.recurring_fine_rule
  71. LEFT JOIN config.hard_due_date hdd ON hdd.id = ccm.hard_due_date
  72. LEFT JOIN actor.org_unit aou3 ON aou3.id = ccm.copy_circ_lib
  73. LEFT JOIN actor.org_unit aou4 ON aou4.id = ccm.copy_owning_lib
  74. LEFT JOIN actor.org_unit aou5 ON aou5.id = ccm.user_home_ou
  75. LEFT JOIN config.circ_matrix_limit_set_map lsm ON lsm.matchpoint = ccm.id
  76. LEFT JOIN config.circ_limit_set cls ON cls.id = lsm.limit_set
  77. LEFT JOIN config.circ_limit_set_circ_mod_map scmm ON scmm.limit_set = cls.id
  78. LEFT JOIN actor.org_unit aoucls ON aoucls.id = cls.owning_lib
  79. ;
  80.  
  81.  
  82. -- for troubleshooting :
  83.  
  84.  
  85. SELECT ccm.id AS "Circ Matrix Matchpoint ID", aou.shortname AS "Circ Short Org Unit Name",
  86. pgt.NAME AS "Permission Group Name", ccm.circ_modifier AS "Circ Modifier", ccm.circulate as "Circulate Boolean",
  87. ccm.is_renewal AS "Renewable Boolean", lsm.id AS "Circ Limit Set Map ID", cls.id as "Circ Limit Set ID",
  88. aoucls.shortname AS "Circ Limit Set Own", cls.items_out, scmm.id as "Circ Mod Map ID", scmm.circ_mod AS "Limit Set Circ Mod"
  89. FROM config.circ_matrix_matchpoint ccm
  90. LEFT JOIN actor.org_unit aou ON aou.id = ccm.org_unit
  91. LEFT JOIN actor.org_unit aou2 ON aou2.id = aou.parent_ou
  92. LEFT JOIN permission.grp_tree pgt ON pgt.id = ccm.grp
  93. LEFT JOIN config.rule_circ_duration dur ON dur.id = ccm.duration_rule
  94. LEFT JOIN config.rule_max_fine maxf ON maxf.id = ccm.max_fine_rule
  95. LEFT JOIN config.rule_recurring_fine recur ON recur.id = ccm.recurring_fine_rule
  96. LEFT JOIN config.hard_due_date hdd ON hdd.id = ccm.hard_due_date
  97. LEFT JOIN config.circ_matrix_limit_set_map lsm ON lsm.matchpoint = ccm.id
  98. LEFT JOIN config.circ_limit_set cls ON cls.id = lsm.limit_set
  99. LEFT JOIN config.circ_limit_set_circ_mod_map scmm ON scmm.limit_set = cls.id
  100. LEFT JOIN actor.org_unit aoucls ON aoucls.id = cls.owning_lib
  101. where aou.id in (108,111,109,187) and pgt.name = 'Juvenile' and ccm.circ_modifier in ('VIDEO',NULL);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement