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 / Testing Content Cafe BTOL
Last active March 9, 2020 14:04
Clear no-content cover art entries from memcached
Here is one way to test to see what Content Cafe is returning.
This does sequential requests for a given ISBN and shows the size and return code.
You need to put in your own username and password for content cafe.
while [ true ]; do curl -s -o /dev/null -w "%{http_code} %{size_download} %{content_type}\n" 'http://images.btol.com/ContentCafe/Jacket.aspx?UserID=xxxxxx&Password=yyyyyyy&NotFound=T&Size=L&Value=9781250179760'; date; done
our results look like the following, notice that the image size bounces between 2723 and 42435, which is the correct image and the no-content image.
@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 / Old Transit Cleanup.sql
Last active January 15, 2020 21:00
Evergreen Old Transits Report
Alert
This copy was sent in transit from x to Y on z. It was in transit for longer than 6 weeks and was
marked missing on <now>. If you find this item and check it in, please email stomproj@larl.org
with a description of where the item was found. Josh Stompro <date>
Note
Title: Lost In-Transit
Value: Source:<shortname> Destination:<Shortname> ON:<date> :This copy was sent in transit from x to Y on z. It was in transit for longer than 6 weeks and was
@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 / database_backup_restore.adoc
Last active August 8, 2019 09:22
Database Backup and Restore

Evergreen Database - Backup and Restore

Tips and tricks on backing up and restoring your Evergreen Database.

Backup to directory format dump. This allows the dump to be done in parrallel for speed, and automatically compresses the output. The downside is that it may not be possible to restore to a different version of postgresql. If you need to move from one version of postgres to another, don’t use the directory format. pg_dump -U evergreen -j 4 -F d -f $BACKUPDIR/$DBNAME-$CURTIME $DBNAME

Restore into a new database

@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 / New Users.sql
Last active June 6, 2019 21:05
Evergreen Database Tricks
-- Set magazine templates for LARL branches where nothing is set already.
insert into actor.usr_setting (usr,name,value) (
select au.id as usr, 'staff_client.copy_editor.templates' as name,
'{"Magazine LARL":{"Location/Collection":{"field":"location","value":"120","type":"attribute"},"LARL_NWRL_CONSORTIUM : Format":{"type":"stat_cat","value":"479","field":"18"},"LARL_NWRL_CONSORTIUM : Reading/Watching Level":{"type":"stat_cat","value":"469","field":"17"},"Circulate as Type":{"field":"circ_as_type","value":"a","type":"attribute"},"Circulation Modifier":{"type":"attribute","field":"circ_modifier","value":"Magazine"},"Status":{"value":"0","field":"status","type":"attribute"},"Price":{"field":"price","value":"5","type":"attribute"}}}'
as value from actor.usr au
join actor.org_unit aou on (au.home_ou = aou.id)
where
aou.parent_ou = 101
and
au.profile in (5,8,9,10,13,65)
@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 / Volume Rename Version 4.sql
Last active October 29, 2018 15:24
Volume rename/merge - Evergreen
-- This version supports moving a call number to a new prefix
-- Move volume to new volume name on same bib. Used to rename volumes that get entered
-- incorrectly.
-- If there is already a volume with the same name, move copies into it. Otherwize rename it.
-- Credit to tsbere for showing me the way with his parts moving function.
-- Update 10-29-2018 - excluded deleted volumes from search for existing volumes.
CREATE OR REPLACE FUNCTION evergreen.larl_moveto_volume(volume_id bigint, new_label text, new_prefix_id bigint)
RETURNS void
LANGUAGE plpgsql
AS $function$
@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