Skip to content

Commit

Permalink
preliminary create all search tables before querying
Browse files Browse the repository at this point in the history
  • Loading branch information
leostera committed Nov 23, 2023
1 parent cc9a6fe commit 4e44766
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions pool/app/filter/repo/repo.ml
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,11 @@ module Sql = struct
let find_filtered_contacts pool ?order_by ?limit use_case filter =
let filter = filter |> CCOption.map (fun f -> f.Entity.query) in
let open Utils.Lwt_result.Infix in
let create_temp_table = create_temporary_participation_table filter in
let create_temp_tables =
[ create_temporary_participation_table filter
; create_temporary_invitation_table filter
]
in
let%lwt template_list =
match filter with
| None -> Lwt.return []
Expand Down Expand Up @@ -375,7 +379,7 @@ module Sql = struct
in
Utils.Database.find_as_transaction
(pool |> Pool_database.Label.value)
~setup:[ drop_temp_table; create_temp_table ]
~setup:(drop_temp_table :: create_temp_tables)
~cleanup:[ drop_temp_table ]
query
||> CCResult.return
Expand All @@ -399,7 +403,11 @@ module Sql = struct
where_fragment
in
let%lwt template_list = find_templates_of_query pool query in
let create_temp_table = create_temporary_participation_table (Some query) in
let create_temp_tables =
[ create_temporary_participation_table (Some query)
; create_temporary_invitation_table (Some query)
]
in
filtered_params MatchesFilter template_list (Some query)
|> CCResult.map_err
(Pool_common.Utils.with_log_error ~src ~level:Logs.Warning ~tags)
Expand All @@ -418,7 +426,7 @@ module Sql = struct
in
Utils.Database.find_as_transaction
(pool |> Pool_database.Label.value)
~setup:[ drop_temp_table; create_temp_table ]
~setup:(drop_temp_table :: create_temp_tables)
~cleanup:[ drop_temp_table ]
matches_filter_request
||> CCOption.map_or ~default (CCInt.equal 1)
Expand Down Expand Up @@ -469,7 +477,11 @@ module Sql = struct
let open Utils.Lwt_result.Infix in
let open Caqti_request.Infix in
let open Dynparam in
let create_temp_table = create_temporary_participation_table query in
let create_temp_tables =
[ create_temporary_participation_table query
; create_temporary_invitation_table query
]
in
let%lwt template_list =
match query with
| None -> Lwt.return []
Expand All @@ -488,7 +500,7 @@ module Sql = struct
in
Utils.Database.find_as_transaction
(pool |> Pool_database.Label.value)
~setup:[ drop_temp_table; create_temp_table ]
~setup:(drop_temp_table :: create_temp_tables)
~cleanup:[ drop_temp_table ]
query
||> CCOption.value ~default:0
Expand Down

0 comments on commit 4e44766

Please sign in to comment.