From 5b50147d586029bd68c58001fb91a1b815e98152 Mon Sep 17 00:00:00 2001 From: Timo Huber Date: Tue, 12 Mar 2024 08:31:28 +0100 Subject: [PATCH] pass cache key to htmx handler --- pool/web/handler/admin_experiments.ml | 1 + pool/web/utils/http_utils.ml | 13 +++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/pool/web/handler/admin_experiments.ml b/pool/web/handler/admin_experiments.ml index a472660d8..cbcc73cb3 100644 --- a/pool/web/handler/admin_experiments.ml +++ b/pool/web/handler/admin_experiments.ml @@ -107,6 +107,7 @@ let index req = HttpUtils.Htmx.handler ~active_navigation:"/admin/experiments" ~error_path:"/admin/experiments" + ~query_cache_key:"experiment-index" ~create_layout ~query:(module Experiment) req diff --git a/pool/web/utils/http_utils.ml b/pool/web/utils/http_utils.ml index 89aa6dcdf..3443ff795 100644 --- a/pool/web/utils/http_utils.ml +++ b/pool/web/utils/http_utils.ml @@ -408,7 +408,7 @@ module Htmx = struct ;; let handler - : ?active_navigation:string -> error_path:string + : ?active_navigation:string -> error_path:string -> ?query_cache_key:string -> query:(module Queryable) -> create_layout: (Rock.Request.t @@ -424,14 +424,19 @@ module Htmx = struct -> ('page Tyxml_html.elt, Pool_common.Message.error) Lwt_result.t) -> Rock.Response.t Lwt.t = - fun ?active_navigation ~error_path ~query:(module Q) ~create_layout req run -> + fun ?active_navigation + ~error_path + ?query_cache_key + ~query:(module Q) + ~create_layout + req + run -> let open Utils.Lwt_result.Infix in extract_happy_path ~src req @@ fun ({ Pool_context.user; _ } as context) -> let cached_key = - (* TODO: Use something else then active naviation as key *) let user_id = user |> Pool_context.get_user_id in - CCOption.( and* ) user_id active_navigation + CCOption.( and* ) user_id query_cache_key in let query = Query.from_request