JOIN permission.grp_tree pgt ON (au.profile = pgt.id)
JOIN asset.copy acp ON (hm.target_copy = acp.id)
LEFT JOIN config.rule_age_hold_protect cahp ON (acp.age_protect = cahp.id)
- LEFT JOIN actor.usr_standing_penalty ausp
- ON ( au.id = ausp.usr AND ( ausp.stop_date IS NULL OR ausp.stop_date > NOW() ) )
- LEFT JOIN config.standing_penalty csp
- ON ( csp.id = ausp.standing_penalty AND csp.block_list LIKE '%CAPTURE%' )
+ LEFT JOIN (
+ SELECT ausp.usr, ausp.id
+ FROM actor.usr_standing_penalty ausp
+ JOIN config.standing_penalty csp
+ ON ( csp.id = ausp.standing_penalty AND csp.block_list LIKE '%CAPTURE%' )
+ WHERE ausp.stop_date IS NULL OR ausp.stop_date > NOW()
+ LIMIT 1
+ ) blocking_penalties ON blocking_penalties.usr = au.id
LEFT JOIN LATERAL (
SELECT OILS_JSON_TO_TEXT(value) AS age
FROM actor.org_unit_ancestor_setting('circ.pickup_hold_stalling.soft', h.pickup_lib)
AND h.cancel_time IS NULL
AND (h.expire_time IS NULL OR h.expire_time > NOW())
AND h.frozen IS FALSE
- AND csp.id IS NULL
+ AND blocking_penalties.id IS NULL
ORDER BY CASE WHEN h.hold_type IN ('R','F') THEN 0 ELSE 1 END, $holdsort
LIMIT $limit
SQL