LP#1879983: adjust available appointment times
authorGalen Charlton <gmc@equinoxinitiative.org>
Tue, 16 Jun 2020 14:41:25 +0000 (10:41 -0400)
committerGalen Charlton <gmc@equinoxinitiative.org>
Tue, 16 Jun 2020 14:41:25 +0000 (10:41 -0400)
This patch ensures that the first available appointment time
falls no sooner than two granularity intervals from the current
time. This is meant to give library staff enough time to stage
items.

The value of two step intervals is arbitrary and could be made configurable in
the future, though it does follow the hard-coding of the horizon in
fetch_to_be_staged().

Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/src/perlmods/lib/OpenILS/Application/Curbside.pm

index d3b76fd..263e77c 100644 (file)
@@ -539,6 +539,13 @@ sub times_for_date {
     my $end_obj = $date_parser->parse_datetime($date.'T'.$close_time)->set_time_zone($tz);
 
     my $now_obj = DateTime->now; # NOTE: does not need timezone set because it gets UTC, not floating, so we can math with it
+    # Add two step intervals to avoid having an appointment be scheduled
+    # sooner than the library could stage the items. Setting the earliest
+    # available time to be no earlier than two intervals from now
+    # is arbitrary and could be made configurable in the future, though
+    # it does follow the hard-coding of the horizon in fetch_to_be_staged().
+    $now_obj->add(seconds => 2 * $gran_seconds);
+
     my $step_obj = $start_obj->clone;
     while (DateTime->compare($step_obj,$end_obj) < 0) { # inside HOO
         if (DateTime->compare($step_obj,$now_obj) >= 0) { # only offer times in the future