use OpenILS::Application::AppUtils;
my $U = "OpenILS::Application::AppUtils";
-# used in build_hold_sort_clause()
+# Used in build_hold_sort_clause(). See the hash %order_by_sprintf_args in
+# that sub to confirm what gets used to replace the formatters, and see
+# nearest_hold() for the main body of the SQL query that these go into.
my %HOLD_SORT_ORDER_BY = (
pprox => 'p.prox',
- hprox => 'actor.org_unit_proximity(%d, h.request_lib)', # $cp->circ_lib
+ hprox => 'actor.org_unit_proximity(%d, h.pickup_lib)', # $cp->call_number->owning_lib
aprox => 'COALESCE(hm.proximity, p.prox)',
approx => 'action.hold_copy_calculated_proximity(h.id, %d, %d)', # $cp,$here
priority => 'pgt.hold_priority',
htime => q!
CASE WHEN
copy_has_not_been_home.result
- THEN actor.org_unit_proximity(%d, acn.owning_lib)
+ THEN actor.org_unit_proximity(%d, h.pickup_lib)
ELSE 999
END
- !,
+ !, # $cp->call_number->owning_lib
shtime => q!
CASE WHEN
copy_has_not_been_home_even_to_idle.result
- THEN actor.org_unit_proximity(%d, acn.owning_lib)
+ THEN actor.org_unit_proximity(%d, h.pickup_lib)
ELSE 999
END
- !,
+ !, # $cp->call_number->owning_lib
);
my ($columns, $cp, $here) = @_;
my %order_by_sprintf_args = (
- hprox => [$cp->circ_lib],
+ hprox => [$cp->call_number->owning_lib],
approx => [$cp->id, $here],
- htime => [$cp->circ_lib],
- shtime => [$cp->circ_lib]
+ htime => [$cp->call_number->owning_lib],
+ shtime => [$cp->call_number->owning_lib]
);
my @clauses;
circ.xact_start >= NOW() - go_home_interval.value
) IS NULL AND (
-- part 2
- SELECT atc.dest <> %d FROM action.transit_copy atc
- JOIN go_home_interval ON (true)
- WHERE
+ SELECT COALESCE(atc.dest <> %d, TRUE)
+ FROM go_home_interval
+ LEFT JOIN action.transit_copy atc ON (
atc.id = (
SELECT MAX(id) FROM action.transit_copy atc_inner
WHERE
atc_inner.target_copy = %d AND
atc_inner.source_send_time < NOW() - go_home_interval.value
)
+ )
) AS result
) !, $cp->id, $cp->circ_lib, $cp->circ_lib, $cp->id);
$joins .= q!
JOIN copy_has_not_been_home ON (true)
- JOIN asset.copy acp ON (hm.target_copy = acp.id)
- JOIN asset.call_number acn ON (acn.id = acp.call_number)
!;
}
my $self = shift;
my $client = shift;
my $here = shift; # just the ID
- my $cp = shift; # now an object, formerly just the ID
+ my $cp = shift; # now an object with call_number fleshed,
+ # formerly just copy ID
my $limit = int(shift()) || 10;
my $age = shift() || '0 seconds';
my $fifo = shift();
INSERT INTO config.best_hold_order (
name,
- pprox, aprox, priority, cut, depth, rtime, htime, hprox
+ approx, pprox, aprox, priority, cut, depth, rtime
) VALUES (
'Traditional',
- 1, 2, 3, 4, 5, 6, 7, 8
+ 1, 2, 3, 4, 5, 6, 7
);
INSERT INTO config.best_hold_order (
name,
- hprox, pprox, aprox, priority, cut, depth, rtime, htime
+ hprox, approx, pprox, aprox, priority, cut, depth, rtime
) VALUES (
'Traditional with Holds-always-go-home',
1, 2, 3, 4, 5, 6, 7, 8
INSERT INTO config.best_hold_order (
name,
- htime, hprox, pprox, aprox, priority, cut, depth, rtime
+ htime, approx, pprox, aprox, priority, cut, depth, rtime
) VALUES (
'Traditional with Holds-go-home',
1, 2, 3, 4, 5, 6, 7, 8