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