Comment 1 for bug 1738844

Revision history for this message
Josh Stompro (u-launchpad-stompro-org) wrote :

Here is a sort clause that tries to keep the default hprox behavior by default, but if the circ.hold_hprox_depth library setting is set for the copy owning location then use that as the depth.

Although I think this might need another COALESCE for the case when the depth is set to lower than what exists for an OU. For the case where one system uses sub systems, while others don't.

I think I'll just hard code the simple version for our needs. If anyone else would find this generally useful then I'll keep working on it. But if it is only something we want to use then I will probably just keep this modification local.

actor.org_unit_proximity(
  (actor.org_unit_ancestor_at_depth(:copyowninglib,
    COALESCE(
      (SELECT oils_json_to_text(value)::INT
           FROM actor.org_unit_ancestor_setting('circ.hold_hprox_depth', :copyowninglib))
      ,
      (SELECT aout.depth
         FROM actor.org_unit aou
         JOIN actor.org_unit_type aout ON aout.id=aou.ou_type
         WHERE aou.id=:copyowninglib
      )
    ))).id
  ,
  (actor.org_unit_ancestor_at_depth(h.pickup_lib,
    COALESCE(
      (SELECT oils_json_to_text(value)::INT
           FROM actor.org_unit_ancestor_setting('circ.hold_hprox_depth', :copyowninglib))
      ,
      (SELECT aout.depth
         FROM actor.org_unit aou
         JOIN actor.org_unit_type aout ON aout.id=aou.ou_type
         WHERE aou.id=:copyowninglib
      )
    ))).id
)