Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug/2353 anonymous exn #492

Merged
merged 3 commits into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions pool/app/custom_field/repo/repo.ml
Original file line number Diff line number Diff line change
Expand Up @@ -293,11 +293,12 @@ module Sql = struct
let where =
{sql|
WHERE pool_custom_fields.published_at IS NOT NULL
AND pool_custom_fields.model = ?
AND pool_custom_fields.possible_duplicates_weight > 0
|sql}
in
let request = select_sql where |> Caqti_type.unit ->* Repo_entity.t in
Database.collect pool request ()
let request = select_sql where |> Repo_entity.Model.t ->* Repo_entity.t in
Database.collect pool request Entity.Model.Contact
>|> multiple_to_entity pool Repo_entity.to_entity get_field_type get_id
;;
end
Expand Down
16 changes: 11 additions & 5 deletions pool/app/job/contact_job/inactivity.ml
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,25 @@ let handle_contact_warnings pool warn_after =
warning_notification_events pool contacts_to_warn
;;

let handle_events pool message = function
let handle_events pool message =
let tags = Database.(Logger.Tags.create pool) in
function
| Error err ->
let open Pool_common in
Logs.err ~src (fun m ->
m
~tags
"%s: An error occurred while making events: %s"
message
(Utils.error_to_string Language.En err));
Utils.failwith err
| Ok (emails, events) ->
Logs.info ~src (fun m ->
m "%s: Found %i contacts to notify due to inactivity" message (CCList.length events));
m
~tags
"%s: Found %i contacts to notify due to inactivity"
message
(CCList.length events));
let%lwt () = Email.handle_event pool (Email.BulkSent emails) in
events |> Lwt_list.iter_s (Contact.handle_event pool)
;;
Expand All @@ -82,11 +89,10 @@ let run_by_tenant pool =
in
let%lwt () =
handle_disable_contacts pool disable_after warn_after
>|> handle_events pool "Pausing inactive users:"
>|> handle_events pool "Pausing inactive users"
in
let%lwt () =
handle_contact_warnings pool warn_after
>|> handle_events pool "Notify inactive users:"
handle_contact_warnings pool warn_after >|> handle_events pool "Notify inactive users"
in
Lwt.return_unit
;;
Expand Down
5 changes: 1 addition & 4 deletions pool/run/run.ml
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,7 @@ let () =
|> with_services services
|> before_start (fun () ->
(Lwt.async_exception_hook
:= fun exn ->
Pool_message.Error.NotHandled (Printexc.to_string exn)
|> Pool_common.Utils.with_log_error ~src
|> ignore);
:= fun exn -> Logger.log_exception ~src ~tags:Logs.Tag.empty exn |> ignore);
Lwt.return @@ Logger.create_logs_dir ())
|> run ~commands ~log_reporter:Logger.reporter)
;;