Skip to content

Instantly share code, notes, and snippets.

@HitScan
HitScan / explain_afhmm.sql
Created May 11, 2023 14:31
Evergreen db function to explain why a particular hold matrix matchpoint is used, including the next 4 that were in the running
-- Show the top 5 hold matrix matchpoints along with the weight fields to explain their ordering
-- Usage: SELECT * FROM action.explain_hold_matrix_matchpoints(pickup_ou, request_ou, match_item, match_user, match_requestor);
-- Note this is just the existing action.find_... with just enough changes to extract useful information
CREATE OR REPLACE FUNCTION action.explain_hold_matrix_matchpoints(pickup_ou integer, request_ou integer, match_item bigint, match_user integer, match_requestor integer)
RETURNS TABLE ( -- Just config.hold_matrix_matchpoint plus numeric fields for weights
m_id integer,
m_active boolean,
m_strict_ou_match boolean,
m_user_home_ou integer,
m_home_ou_prox_weight numeric,
@HitScan
HitScan / template.tt2
Created January 30, 2023 19:55
AutorenewNotification template with sorting and conditional subject
[%- USE date;
user = target.0.usr;
fcirc = [];
fdata = [];
rcirc = [];
rdata = [];
FOR circ IN target;
SET idx = loop.count - 1;
SET udata = user_data.$idx;
@HitScan
HitScan / clark-kent.service
Created September 25, 2017 12:28
Systemd files for OpenSRF / Clark Kent
[Unit]
Description=Evergreen Reporter
After=opensrf.service
BindsTo=opensrf.service
[Service]
User=opensrf
Group=opensrf
Type=forking
Environment=PATH=/openils/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin