From 1b7e6e5a73d67537c2b24af09bc12562adfce639 Mon Sep 17 00:00:00 2001 From: fr33domlover Date: Fri, 12 Feb 2016 00:01:41 +0000 Subject: [PATCH] Use the git code to add last change time to main view query --- src/Vervis/Persist.hs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/Vervis/Persist.hs b/src/Vervis/Persist.hs index 2f62201..d097840 100644 --- a/src/Vervis/Persist.hs +++ b/src/Vervis/Persist.hs @@ -30,11 +30,14 @@ where import Control.Monad.IO.Class (liftIO) import Data.Text (Text) +import Data.Traversable (forM) import Database.Esqueleto ((^.), (&&.), (==.)) import Database.Persist hiding ((==.)) import Database.Persist.Sqlite hiding ((==.)) import Database.Persist.TH +import Vervis.Git +import qualified Data.Text as T import qualified Database.Esqueleto as E share [mkPersist sqlSettings, mkMigrate "migrateAll"] [persistLowerCase| @@ -116,7 +119,7 @@ mainViewQuery = runSqlite ":memory:" $ do insert_ $ Repo "repo11" proj6Id Nothing Nothing insert_ $ Repo "repo12" proj6Id Nothing Nothing - rows <- E.select $ E.from $ \ (sharer, project, repo) -> do + repos <- E.select $ E.from $ \ (sharer, project, repo) -> do E.where_ $ project ^. ProjectSharer ==. sharer ^. SharerId &&. repo ^. RepoProject ==. project ^. ProjectId @@ -130,4 +133,18 @@ mainViewQuery = runSqlite ":memory:" $ do , project ^. ProjectIdent , repo ^. RepoIdent ) + rows <- liftIO $ forM repos $ \ (E.Value sharer, E.Value project, E.Value repo) -> do + let path = + T.unpack $ + T.intercalate "/" + [ "state2" + , "people" + , sharer + , project + , repo + ] + dt <- lastChange path + ago <- timeAgo dt + return (sharer, project, repo, T.pack ago) + liftIO $ mapM_ print rows