From 48ebe7b2bdd47654261813cc6b0b26196b93883b Mon Sep 17 00:00:00 2001 From: Dmitry Zuikov Date: Tue, 26 Mar 2024 11:54:17 +0300 Subject: [PATCH] wip --- .../lib/HBS2/Git/Oracle/Run.hs | 23 ++++++++----------- hbs2-git/hbs2-git.cabal | 2 ++ 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/hbs2-git/hbs2-git-oracle/lib/HBS2/Git/Oracle/Run.hs b/hbs2-git/hbs2-git-oracle/lib/HBS2/Git/Oracle/Run.hs index b5176e21..2e021065 100644 --- a/hbs2-git/hbs2-git-oracle/lib/HBS2/Git/Oracle/Run.hs +++ b/hbs2-git/hbs2-git-oracle/lib/HBS2/Git/Oracle/Run.hs @@ -14,8 +14,10 @@ import HBS2.Git.Data.Tx import Data.Maybe -import Lens.Micro.Platform +import Lens.Micro.Platform hiding ( (.=) ) +import Data.Aeson +import Data.Aeson.Encode.Pretty qualified as A import Data.Word import Streaming.Prelude qualified as S import Codec.Serialise @@ -202,22 +204,15 @@ runDump = do let rhf = [ (h,f) | (GitRepoHeadFact h f) <- universeBi facts ] & HM.fromList - for_ (HM.toList rf) $ \(k, GitRepoFact1{..}) -> do + items <- S.toList_ $ for_ (HM.toList rf) $ \(k, GitRepoFact1{..}) -> do let d = HM.lookup k rhf let nm = maybe "" gitRepoName d let brief = maybe "" gitRepoBrief d - liftIO $ print $ "repo" - <+> pretty gitLwwRef - <+> pretty nm - <+> pretty brief - pure () - -- let rhf = [ (h,f) | (GitRepoHeadFact h f) <- universeBi facts ] + S.yield $ object [ "item_id" .= show (pretty gitLwwRef) + , "item_title" .= show (pretty nm) + , "item_brief" .= show (pretty brief) + ] - -- lift do - -- for_ rf $ \f -> do - -- liftIO $ print $ pretty (hashObject @HbSync (serialise f), f) - - -- for_ rhf $ \(h,f) -> do - -- liftIO $ print $ pretty (h, f) + liftIO $ LBS.putStr $ A.encodePretty $ object [ "items" .= items ] diff --git a/hbs2-git/hbs2-git.cabal b/hbs2-git/hbs2-git.cabal index 49256766..e5b730df 100644 --- a/hbs2-git/hbs2-git.cabal +++ b/hbs2-git/hbs2-git.cabal @@ -60,6 +60,8 @@ common shared-properties , db-pipe , suckless-conf , attoparsec + , aeson + , aeson-pretty , atomic-write , bytestring , binary