fix Show overdue tentative workouts

Commit
57603316c819b592bc89e34de163ad9186242326
Author
Marius Peter <dev@marius-peter.com>
Author date
Committer
Marius Peter <dev@marius-peter.com>
Committer date
Changed files
lib/web/handlers_logbook.ml
index 23179cc9..8629d3aa 100644..100644
@@ -81,14 +81,17 @@
81 81 (Prescription.Routine.recovery_after routine
82 82 previous_prescription)
83 83 in
84 Removed: if planned_at < now then []
85 Removed: else
84 Added: let scheduled at_unix =
86 85 {
87 Removed: at_unix = planned_at;
86 Added: at_unix;
88 87 routine_name = Prescription.Routine.name routine;
89 88 workout_name = Prescription.Workout.name next;
90 89 groups = groups_of_prescription next;
91 90 }
91 Added: in
92 Added: if planned_at < now then [ scheduled now ]
93 Added: else
94 Added: scheduled planned_at
92 95 :: loop next
93 96 (Recovery.timestamp_of_unix_seconds planned_at)
94 97 (remaining - 1)
test/web/logbook.ml
index 8ef3100a..878bb328 100644..100644
@@ -87,6 +87,35 @@
87 87 Alcotest.(check bool)
88 88 "the old entry list is absent" true
89 89 (Option.is_none (index_from ~needle:"logbook-entry" page 0)) );
90 Added: ( "the Logbook keeps an overdue next workout tentative",
91 Added: `Quick,
92 Added: fun () ->
93 Added: let c, now, _repo = clocked_client () in
94 Added: now := day 10;
95 Added: let _ = sign_in_new c in
96 Added: let _ = start_day_one c in
97 Added: record_all_day_one_slots c;
98 Added: let token = Option.get (csrf_token (body (get c "/workout"))) in
99 Added: let _ = post c "/workout/finish" [ ("dream.csrf", token) ] in
100 Added: (* Day 2 was due after recovery, but was not performed. The Logbook
101 Added: must keep Day 2 visible today. It must not advance to Day 3. *)
102 Added: now := day 20;
103 Added: let page = body (get c "/logbook") in
104 Added: Alcotest.(check bool)
105 Added: "today names the overdue next workout" true
106 Added: (Option.is_some
107 Added: (index_from ~needle:"21: planned Day 2, today" page 0));
108 Added: Alcotest.(check bool)
109 Added: "the overdue tentative workout is displayed" true
110 Added: (Option.is_some
111 Added: (index_from ~needle:"Ideal Routine, Day 2" page 0));
112 Added: Alcotest.(check bool)
113 Added: "the tentative workout is planned today" true
114 Added: (Option.is_some
115 Added: (index_from ~needle:"Planned on 21st January 1970" page 0));
116 Added: Alcotest.(check bool)
117 Added: "the routine does not advance silently" true
118 Added: (Option.is_none (index_from ~needle:"planned Day 3" page 0)) );
90 119 ( "a faster repeat of the identical workout shows a favourable \
91 120 duration delta",
92 121 `Quick,