Use the git code to add last change time to main view query
This commit is contained in:
parent
229bdead0e
commit
1b7e6e5a73
1 changed files with 18 additions and 1 deletions
|
@ -30,11 +30,14 @@ where
|
||||||
|
|
||||||
import Control.Monad.IO.Class (liftIO)
|
import Control.Monad.IO.Class (liftIO)
|
||||||
import Data.Text (Text)
|
import Data.Text (Text)
|
||||||
|
import Data.Traversable (forM)
|
||||||
import Database.Esqueleto ((^.), (&&.), (==.))
|
import Database.Esqueleto ((^.), (&&.), (==.))
|
||||||
import Database.Persist hiding ((==.))
|
import Database.Persist hiding ((==.))
|
||||||
import Database.Persist.Sqlite hiding ((==.))
|
import Database.Persist.Sqlite hiding ((==.))
|
||||||
import Database.Persist.TH
|
import Database.Persist.TH
|
||||||
|
import Vervis.Git
|
||||||
|
|
||||||
|
import qualified Data.Text as T
|
||||||
import qualified Database.Esqueleto as E
|
import qualified Database.Esqueleto as E
|
||||||
|
|
||||||
share [mkPersist sqlSettings, mkMigrate "migrateAll"] [persistLowerCase|
|
share [mkPersist sqlSettings, mkMigrate "migrateAll"] [persistLowerCase|
|
||||||
|
@ -116,7 +119,7 @@ mainViewQuery = runSqlite ":memory:" $ do
|
||||||
insert_ $ Repo "repo11" proj6Id Nothing Nothing
|
insert_ $ Repo "repo11" proj6Id Nothing Nothing
|
||||||
insert_ $ Repo "repo12" 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_ $
|
E.where_ $
|
||||||
project ^. ProjectSharer ==. sharer ^. SharerId &&.
|
project ^. ProjectSharer ==. sharer ^. SharerId &&.
|
||||||
repo ^. RepoProject ==. project ^. ProjectId
|
repo ^. RepoProject ==. project ^. ProjectId
|
||||||
|
@ -130,4 +133,18 @@ mainViewQuery = runSqlite ":memory:" $ do
|
||||||
, project ^. ProjectIdent
|
, project ^. ProjectIdent
|
||||||
, repo ^. RepoIdent
|
, 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
|
liftIO $ mapM_ print rows
|
||||||
|
|
Loading…
Reference in a new issue