LP#1879983: Create and protect a floor on appt granularity
authorMike Rylander <mrylander@gmail.com>
Mon, 27 Jul 2020 18:10:14 +0000 (14:10 -0400)
committerMike Rylander <mrylander@gmail.com>
Mon, 27 Jul 2020 18:10:14 +0000 (14:10 -0400)
If bare numbers are entered, they are interpreted as a number of
seconds.  The most likely intent is minutes, so we force that unit.

Additionally, this commit sets a hard floor of 10 minutes on appointment
granularity.

Signed-off-by: Mike Rylander <mrylander@gmail.com>
Open-ILS/src/perlmods/lib/OpenILS/Application/Curbside.pm

index a98a66f..7cc57f5 100644 (file)
@@ -518,7 +518,10 @@ sub times_for_date {
     return $conn->respond_complete unless ($start_obj);
 
     my $gran = $U->ou_ancestor_setting_value($org, 'circ.curbside.granularity') || '15 minutes';
+    $gran .= ' minutes' if ($gran =~ /^\s*\d+\s*$/); # Assume minutes for bare numbers (maybe surrounded by spaces)
+
     my $gran_seconds = interval_to_seconds($gran);
+    $gran_seconds = 600 if ($gran_seconds < 600); # No smaller than 10 minute intervals
 
     my $max = $U->ou_ancestor_setting_value($org, 'circ.curbside.max_concurrent') || 10;