Best Sort Order - System level sort for copy owning location and hold pickup location

Bug #1738844 reported by Josh Stompro
14
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Evergreen
Confirmed
Wishlist
Unassigned

Bug Description

Hello, we would like a best hold sort order option that will always give holds in the same system as the copy owning location priority.

This would be like the hprox option, which gives holds with the same pickup location as the copy owning location priority.

I first thought that it would work to grab the copy owning lib parent and the hold pickup lib parent, but that doesn't work for more complicated org unit hierarchies, where there may be sub system groups, or sub branch pickup locations.

One option would be to make the hprox sort depth aware, add an org unit setting that specifies a depth that is taken into account when calculating the hprox sort. The default setting would use the depth of the passed org units. That way the behavior wouldn't change by default.

Another option is to create a new sort option for this, hdprox, Home proximity with depth. But since I cannot think of why a system would use both hprox and hdprox at the same time, I'm really leaning towards modifying hprox.

In my testing, something along the lines of this works for a system level hprox.
actor.org_unit_proximity((actor.org_unit_ancestor_at_depth(:copyowninglib,1)).id, (actor.org_unit_ancestor_at_depth(h.pickup_lib,1)).id)

If I wanted to just hard code it to depth 1 (system in our case) I think I could just modify the line at:
http://git.evergreen-ils.org/?p=working/Evergreen.git;a=blob;f=Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm;hb=HEAD#l25

Josh

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
)

Revision history for this message
Mike Rylander (mrylander) wrote :

Josh,

This is interesting. One note, generally when there's a YAOUS or other setting that specifies a depth, it's the value of the depth field from the aout table, rather than its id. That is actually to allow the situation you mention, where the org tree may be unbalanced.

Thanks for looking into this, it looks like it could be a useful improvement!

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

Mike, Thanks for the feedback, but I don't understand your comment about using the value of the depth field vs the id. Could you suggest an example I could look at, or go into more detail when you have time.

Thanks
Josh

Elaine Hardy (ehardy)
tags: added: holds wishlist
Revision history for this message
Josh Stompro (u-launchpad-stompro-org) wrote :

Here is what we use in production to convert hprox to being owning system proximity to pickup library system proximity.

https://gitlab.com/LARL/evergreen-larl/-/commit/1070061dcbb8777439de698733b7efad1eb14fd2

Note: bug #1869794 is an example of adding a new best-hold selection sort order option.

Josh

Dan Briem (dbriem)
tags: added: circ-holds
removed: holds
tags: added: sorting
removed: wishlist
Changed in evergreen:
importance: Undecided → Wishlist
status: New → Confirmed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.