Skip to content

Instantly share code, notes, and snippets.

View stompro's full-sized avatar

Josh Stompro stompro

  • Moorhead, MN USA
View GitHub Profile
@stompro
stompro / Xul example.json
Created January 24, 2020 21:23
Evergreen Item Templates XUL vs Web
"hrefmn Ad Bk Ref MN Non Fiction": {
"Status": {
"value": "5",
"field": "status",
"type": "attribute"
},
"Price": {
"value": "30.00",
"field": "price",
"type": "attribute"
@stompro
stompro / Sync old and new item alerts.sql
Last active July 30, 2021 16:17
Evergreen Old and New Item Alert Sync
-- Copy old asset.copy(alert_message) to asset.copy_alert and vice versa
-- For situations when some staff are still using xul and some have moved to web staff client.
CREATE or replace FUNCTION larl_copy_old_new_alert() RETURNS trigger AS $larl_copy_old_new_alert$
BEGIN
if TG_OP = 'UPDATE' then
-- alert_message is now null - mark matching asset.copy_alert as clear
if NEW.alert_message is null then
update asset.copy_alert
@stompro
stompro / email-lost-post.sql
Created September 17, 2019 16:07
Evergreen Email Bills Preprocessing
\echo Post-Hook SQL Scripts - Run after new events have been created.
begin;
\echo Summary of events for event_def=117
select state,count(id) from action_trigger.event where event_def=117 group by state;
\echo Change event to invalid if patron has no email address.
update action_trigger.event ate
set state='invalid',update_time=now()
@stompro
stompro / Auditor tables bloat cleanup.sql
Last active July 15, 2019 03:53
Evergreen ILS Index and Table Bloat Notes
-- Auditor Bloat and cluster
--------------------------------
-- cluster asset_copy_history
-- Create index to cluster on
create index aud_asset_cp_cluster on auditor.asset_copy_history using btree(id,audit_id);
cluster verbose auditor.asset_copy_history using aud_asset_cp_cluster;
--remove cluster index
@stompro
stompro / evergreen
Created February 8, 2019 17:33
cat /etc/init.d/evergreen - Evergreen startup scripts
#!/bin/bash
### BEGIN INIT INFO
# Provides: evergreen
# Required-Start: $remote_fs $syslog ejabberd
# Should-Start: postgresql memcached apache2
# Required-Stop: $remote_fs $syslog
# Should-Stop: apache2 memcached postgresql
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
@stompro
stompro / auth-purge-00-notes.txt
Last active June 16, 2018 18:53
Purge unused authority records - Evergreen ILS
Before you try to clean up your authority records, you should have run the authority linking scripts,
and then set them up to run on a regular basis via cron.
#Link bibs to authorities
/openils/bin/authority_control_fields.pl -a
#Link authorities to other authorities.
/openils/bin/authority_authority_linker.pl -a
@stompro
stompro / stat-cat-cross-tab.sql
Created April 6, 2018 21:32
Stat Cat Cross Tab Report
rollback;
begin;
select larl_temp.colpivot('_output',$$
select --acn.record
acp.id
, acp.barcode
, acp.circ_modifier
,ascc.name, asce.value
@stompro
stompro / series fixes.sql
Last active March 22, 2018 14:55
Series fixes
-- List of all 490 a
select mrfr.value,count(distinct mrfr.record),string_agg(distinct mrfr.record::text,', ') from metabib.real_full_rec mrfr
where
mrfr.tag='490'
and mrfr.subfield='a'
--limit 100
group by mrfr.value
@stompro
stompro / allow-larl-holds.sql
Created March 2, 2018 15:10
Disable age hold protection when item has sat on the shelf for a certain amount of time.
\pset format html
\echo <h1>Allow LARL holds on NWRL age protected items</h1>
\echo <h2>NWRL Items that could fill LARL holds</h2>
begin;
-- Create temp table to store NWRL copies that are canidates for removing age hold protection.
create temporary table nwrl_new
on commit drop
@stompro
stompro / batch purge circ history.sql
Created January 26, 2018 14:10
Evergreen Circ History - Allow staff to enable/disable
begin;
-- Look for preference set to null, blank or false and remove it.
delete from actor.usr_setting aus
where
aus.name='history.circ.retention_start'
and (aus.value is null or aus.value = 'false' or aus.value='')
returning aus.*
;