diff --git a/pool/cqrs_command/experiment_command.ml b/pool/cqrs_command/experiment_command.ml index 9dabdde1c..feb3f3a01 100644 --- a/pool/cqrs_command/experiment_command.ml +++ b/pool/cqrs_command/experiment_command.ml @@ -546,6 +546,7 @@ module CreateFilter : sig val handle : ?tags:Logs.Tag.set -> Experiment.t + -> Assignment.event list * Email.dispatch list -> t -> (Pool_event.t list, Pool_message.Error.t) result @@ -559,7 +560,12 @@ end = struct Filter.create ~id None query |> return ;; - let handle ?(tags = Logs.Tag.empty) experiment filter = + let handle + ?(tags = Logs.Tag.empty) + experiment + (assignment_events, emails) + filter + = Logs.info ~src (fun m -> m "Handle command CreateFilter" ~tags); let open CCResult in let updated = @@ -568,10 +574,16 @@ end = struct ; matcher_notification_sent = MatcherNotificationSent.create false } in + let assignment_events = + assignment_events |> CCList.map Pool_event.assignment + in + let email_event = Email.BulkSent emails |> Pool_event.email in Ok - [ Filter.Created filter |> Pool_event.filter - ; Experiment.Updated (experiment, updated) |> Pool_event.experiment - ] + ([ Filter.Created filter |> Pool_event.filter + ; Experiment.Updated (experiment, updated) |> Pool_event.experiment + ] + @ assignment_events + @ [ email_event ]) ;; let effects id = diff --git a/pool/web/handler/admin_filter.ml b/pool/web/handler/admin_filter.ml index b5111a2f6..9bd606ecd 100644 --- a/pool/web/handler/admin_filter.ml +++ b/pool/web/handler/admin_filter.ml @@ -130,7 +130,8 @@ let write action req = | None -> let open CreateFilter in let* filter = create_filter key_list template_list query |> lift in - handle ~tags exp filter |> lift + let* matcher_events = matcher_events filter in + handle ~tags exp matcher_events filter |> lift | Some filter -> let open UpdateFilter in let* updated =