From facb1e40a9146a9caf25313cb84735f03e7334cf Mon Sep 17 00:00:00 2001 From: Timo Huber Date: Tue, 15 Aug 2023 07:54:54 +0200 Subject: [PATCH] upate num_show_ups --- pool/app/contact_counter/contact_counter.ml | 19 +++++++++---------- pool/app/contact_counter/contact_counter.mli | 2 +- pool/cqrs_command/assignment_command.ml | 2 +- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/pool/app/contact_counter/contact_counter.ml b/pool/app/contact_counter/contact_counter.ml index 946653194..bfce369d4 100644 --- a/pool/app/contact_counter/contact_counter.ml +++ b/pool/app/contact_counter/contact_counter.ml @@ -80,24 +80,23 @@ let update_on_assignment_update let open Assignment in let open Contact in let open CCOption.Infix in - (* update_num_show_ups is missing *) let contact = let open NoShow in - match no_show >|= value, updated_no_show >|= value with - | Some true, (Some false | None) -> update_num_no_shows ~step:(-1) contact - | (Some false | None), Some true -> update_num_no_shows ~step:1 contact - | None, None | Some _, Some _ | Some _, None | None, Some false -> contact + match no_show >|= value, updated_no_show |> value with + | Some true, false -> + contact |> update_num_no_shows ~step:(-1) |> update_num_show_ups ~step:1 + | (Some false | None), true -> + contact |> update_num_no_shows ~step:1 |> update_num_show_ups ~step:(-1) + | Some true, true | Some false, false | None, false -> contact in let contact = let open NoShow in if participated_in_other_assignments then contact else ( - match no_show >|= value, updated_no_show >|= value with - | Some true, (Some false | None) -> - update_num_participations ~step:1 contact - | Some false, (Some true | None) -> - update_num_participations ~step:(-1) contact + match no_show >|= value, updated_no_show |> value with + | Some true, false -> update_num_participations ~step:1 contact + | Some false, true -> update_num_participations ~step:(-1) contact | _ -> contact) in contact diff --git a/pool/app/contact_counter/contact_counter.mli b/pool/app/contact_counter/contact_counter.mli index 30db18ac8..53058e17f 100644 --- a/pool/app/contact_counter/contact_counter.mli +++ b/pool/app/contact_counter/contact_counter.mli @@ -24,6 +24,6 @@ val update_on_assignment_deletion val update_on_assignment_update : Assignment.t - -> Assignment.NoShow.t option + -> Assignment.NoShow.t -> bool -> Contact.t diff --git a/pool/cqrs_command/assignment_command.ml b/pool/cqrs_command/assignment_command.ml index 23df4cbc4..92a9cad3b 100644 --- a/pool/cqrs_command/assignment_command.ml +++ b/pool/cqrs_command/assignment_command.ml @@ -309,7 +309,7 @@ end = struct let contact_counters = Contact_counter.update_on_assignment_update assignment - (Some no_show) + no_show participated_in_other_assignments |> Contact.updated |> Pool_event.contact