From 85e0d4b99a481679d3dd1fd1e48b075c12b62087 Mon Sep 17 00:00:00 2001 From: Dmitry Zuikov Date: Tue, 1 Oct 2024 10:34:27 +0300 Subject: [PATCH] wip --- hbs2-git-dashboard/app/GitDashBoard.hs | 27 +++++++++++++++++-- .../HBS2/Git/DashBoard/State.hs | 6 ++++- .../HBS2/Git/DashBoard/State/Index/Peer.hs | 8 +++--- hbs2-git-dashboard/hbs2-git-dashboard.cabal | 1 + 4 files changed, 35 insertions(+), 7 deletions(-) diff --git a/hbs2-git-dashboard/app/GitDashBoard.hs b/hbs2-git-dashboard/app/GitDashBoard.hs index fa6cdfc7..8ab0b295 100644 --- a/hbs2-git-dashboard/app/GitDashBoard.hs +++ b/hbs2-git-dashboard/app/GitDashBoard.hs @@ -28,9 +28,10 @@ import HBS2.Git.Web.Html.Root import HBS2.Git.Web.Html.Issue import HBS2.Git.Web.Html.Repo import HBS2.Git.Web.Html.Fixme - import HBS2.Peer.CLI.Detect +import DBPipe.SQLite + import Data.Config.Suckless.Script import Lucid (renderTextT,HtmlT(..),toHtml) @@ -142,7 +143,6 @@ runDashBoardM m = do xdgData <- liftIO $ getXdgDirectory XdgData hbs2_git_dashboard let dataDir = xdgData - let dbFile = xdgData "state.db" -- FIXME: unix-socket-from-config soname <- detectRPC `orDie` "hbs2-peer rpc not found" @@ -191,6 +191,18 @@ runDashBoardM m = do lwwAPI sto + void $ ContT $ withAsync do + fix \next -> do + dbe' <- readTVarIO (_db env) + case dbe' of + Just dbe -> do + notice $ green "Aquired database!" + runPipe dbe + + Nothing -> do + pause @'Seconds 5 + next + void $ ContT $ withAsync do q <- withDashBoardEnv env $ asks _pipeline forever do @@ -678,6 +690,17 @@ theDict = do t <- asks _dashBoardIndexIgnoreCaches atomically $ writeTVar t False + entry $ bindMatch "debug:build-commit-index" $ nil_ $ \case + [SignPubKeyLike lw] -> lift do + buildCommitTreeIndex (LWWRefKey lw) + + _ -> throwIO $ BadFormException @C nil + + -- rs <- selectRepoFixme + -- for_ rs $ \(r,f) -> do + -- liftIO $ print $ pretty r <+> pretty (AsBase58 f) + + entry $ bindMatch "debug:select-repo-fixme" $ nil_ $ const $ lift do rs <- selectRepoFixme for_ rs $ \(r,f) -> do diff --git a/hbs2-git-dashboard/hbs2-git-dashboard-core/HBS2/Git/DashBoard/State.hs b/hbs2-git-dashboard/hbs2-git-dashboard-core/HBS2/Git/DashBoard/State.hs index f694a10a..8bfafb14 100644 --- a/hbs2-git-dashboard/hbs2-git-dashboard-core/HBS2/Git/DashBoard/State.hs +++ b/hbs2-git-dashboard/hbs2-git-dashboard-core/HBS2/Git/DashBoard/State.hs @@ -769,8 +769,12 @@ buildCommitTreeIndex lww = do commits <- listCommits env <- ask + ignoreCaches <- getIgnoreCaches + for_ commits $ \co -> void $ runMaybeT do - checkCommitProcessed co >>= guard . not + done <- checkCommitProcessed co + let skip = done && not ignoreCaches + guard (not skip) updateRepoData env co updateForks diff --git a/hbs2-git-dashboard/hbs2-git-dashboard-core/HBS2/Git/DashBoard/State/Index/Peer.hs b/hbs2-git-dashboard/hbs2-git-dashboard-core/HBS2/Git/DashBoard/State/Index/Peer.hs index ec776d46..d9644e48 100644 --- a/hbs2-git-dashboard/hbs2-git-dashboard-core/HBS2/Git/DashBoard/State/Index/Peer.hs +++ b/hbs2-git-dashboard/hbs2-git-dashboard-core/HBS2/Git/DashBoard/State/Index/Peer.hs @@ -81,9 +81,9 @@ updateIndexFromPeer = do Right hxs -> do for_ hxs $ \htx -> void $ runMaybeT do - -- done <- lift $ withState $ isProcessed (HashRef $ hashObject @HbSync (serialise (lw,htx))) + done <- lift $ withState $ isProcessed (HashRef $ hashObject @HbSync (serialise (lw,htx))) - -- guard (not done) + guard (not done) getBlock sto (fromHashRef htx) >>= toMPlus <&> deserialiseOrFail @(RefLogUpdate L4Proto) @@ -105,12 +105,12 @@ updateIndexFromPeer = do let rlwwseq = RepoLwwSeq (fromIntegral $ lwwSeq wv) insertRepoHead l rlwwseq (RepoRefLog rk) tx rh rhead - -- insertProcessed (HashRef $ hashObject @HbSync (serialise (l,coerce @_ @HashRef tx))) + insertProcessed (HashRef $ hashObject @HbSync (serialise (l,coerce @_ @HashRef tx))) for_ fme $ \f -> do insertRepoFixme l rlwwseq f - buildCommitTreeIndex (coerce lw) + -- buildCommitTreeIndex (coerce lw) fxe <- selectRepoFixme diff --git a/hbs2-git-dashboard/hbs2-git-dashboard.cabal b/hbs2-git-dashboard/hbs2-git-dashboard.cabal index d312797e..4141c31f 100644 --- a/hbs2-git-dashboard/hbs2-git-dashboard.cabal +++ b/hbs2-git-dashboard/hbs2-git-dashboard.cabal @@ -178,6 +178,7 @@ executable hbs2-git-dashboard , hbs2-git-dashboard-core , hbs2-peer , suckless-conf + , db-pipe , binary , bytestring