1
0
Fork 0
mirror of https://code.sup39.dev/repos/Wqawg synced 2024-12-27 18:54:53 +09:00

Use the git code to add last change time to main view query

This commit is contained in:
fr33domlover 2016-02-12 00:01:41 +00:00
parent 229bdead0e
commit 1b7e6e5a73

View file

@ -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