From 366dd31732e82caf2eb74f4b4f6b8dadb8ac5e47 Mon Sep 17 00:00:00 2001 From: Vijay Gupta Date: Mon, 2 Dec 2024 13:00:18 +0530 Subject: [PATCH] backend: update flake.lock and flake.nix for async pipeline operation; add findAllFromKvRedis function --- flake.lock | 7 ++++--- flake.nix | 2 +- .../src/Kernel/Beam/Functions.hs | 21 +++++++++++++++++++ 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/flake.lock b/flake.lock index 6dfc9924a..523ca02a3 100644 --- a/flake.lock +++ b/flake.lock @@ -370,15 +370,16 @@ "tinylog": "tinylog" }, "locked": { - "lastModified": 1732689486, - "narHash": "sha256-geIUi3MO2l91Ww3lPwztyVdt3gYf4bvqUKopQYfeXxU=", + "lastModified": 1733133959, + "narHash": "sha256-pKEdMRCCk6Qbxv9FlJMWi7E7cO1BDpI3c2kD6vuzw9w=", "owner": "nammayatri", "repo": "euler-hs", - "rev": "1d1f4490d5188d0fc07111d4a9be9e8bcb7dfc32", + "rev": "ef6b08a3d6a3cba5f95783a31791d81d266fd323", "type": "github" }, "original": { "owner": "nammayatri", + "ref": "backend/async-pipeline-operation", "repo": "euler-hs", "type": "github" } diff --git a/flake.nix b/flake.nix index 98c09dfb4..881ca7f39 100644 --- a/flake.nix +++ b/flake.nix @@ -13,7 +13,7 @@ prometheus-haskell.inputs.haskell-flake.follows = "common/haskell-flake"; euler-hs = { - url = "github:nammayatri/euler-hs"; + url = "github:nammayatri/euler-hs/backend/async-pipeline-operation"; inputs.nixpkgs.follows = "nixpkgs"; inputs.haskell-flake.follows = "haskell-flake"; }; diff --git a/lib/mobility-core/src/Kernel/Beam/Functions.hs b/lib/mobility-core/src/Kernel/Beam/Functions.hs index 0f0efa58a..7ef6ef3b0 100644 --- a/lib/mobility-core/src/Kernel/Beam/Functions.hs +++ b/lib/mobility-core/src/Kernel/Beam/Functions.hs @@ -29,6 +29,7 @@ module Kernel.Beam.Functions findAllWithKVAndConditionalDB, findOneWithKVRedis, logQueryData, + findAllFromKvRedis, ) where @@ -317,6 +318,26 @@ findAllWithKVAndConditionalDB where' orderBy = do pure $ catMaybes res' Left err -> throwError $ InternalError $ show err +findAllFromKvRedis :: + forall table m r a. + ( BeamTableFlow table m, + CacheFlow m r, + EsqDBFlow m r, + FromTType' (table Identity) a + ) => + Where Postgres table -> + Maybe (OrderBy table) -> + m [a] +findAllFromKvRedis where' orderBy = do + updatedMeshConfig <- setMeshConfig (modelTableName @table) (modelSchemaName @table) meshConfig + dbConf' <- getReadDBConfigInternal (modelTableName @table) + result <- KV.findAllFromKvRedis dbConf' updatedMeshConfig where' orderBy + case result of + Right res -> do + res' <- mapM fromTType' res + pure $ catMaybes res' + Left err -> throwError $ InternalError $ show err + -- findAllWithOptions -- findAllWithOptionsKV ::