mirror of
https://code.sup39.dev/repos/Wqawg
synced 2024-12-27 18:34:52 +09:00
Write initial main view query with Esqueleto
This commit is contained in:
parent
5734e720ad
commit
552b17e219
2 changed files with 26 additions and 5 deletions
|
@ -30,10 +30,13 @@ where
|
|||
|
||||
import Control.Monad.IO.Class (liftIO)
|
||||
import Data.Text (Text)
|
||||
import Database.Persist
|
||||
import Database.Persist.Sqlite
|
||||
import Database.Esqueleto ((^.), (&&.), (==.))
|
||||
--import Database.Persist hiding ((==.))
|
||||
import Database.Persist.Sqlite hiding ((==.))
|
||||
import Database.Persist.TH
|
||||
|
||||
import qualified Database.Esqueleto as E
|
||||
|
||||
share [mkPersist sqlSettings, mkMigrate "migrateAll"] [persistLowerCase|
|
||||
|
||||
IrcChannel
|
||||
|
@ -67,12 +70,12 @@ Project
|
|||
UniqueProject ident sharer
|
||||
|
||||
Repo
|
||||
name Text --CI
|
||||
ident Text --CI
|
||||
project ProjectId
|
||||
irc IrcChannelId Maybe
|
||||
ml Text Maybe
|
||||
|
||||
UniqueRepo name project
|
||||
UniqueRepo ident project
|
||||
|
||||
PersonInGroup
|
||||
person PersonId
|
||||
|
@ -82,4 +85,21 @@ PersonInGroup
|
|||
|
||||
|]
|
||||
|
||||
--mainViewQuery = --TODO
|
||||
mainViewQuery :: IO ()
|
||||
mainViewQuery = runSqlite ":memory:" $ do
|
||||
runMigration migrateAll
|
||||
rows <- E.select $ E.from $ \ (sharer, project, repo) -> do
|
||||
E.where_ $
|
||||
project ^. ProjectSharer ==. sharer ^. SharerId &&.
|
||||
repo ^. RepoProject ==. project ^. ProjectId
|
||||
E.orderBy
|
||||
[ E.asc $ sharer ^. SharerIdent
|
||||
, E.asc $ project ^. ProjectIdent
|
||||
, E.asc $ repo ^. RepoIdent
|
||||
]
|
||||
return
|
||||
( sharer ^. SharerIdent
|
||||
, project ^. ProjectIdent
|
||||
, repo ^. RepoIdent
|
||||
)
|
||||
liftIO $ mapM_ print rows
|
||||
|
|
|
@ -38,6 +38,7 @@ library
|
|||
, base >=4.8 && <5
|
||||
, case-insensitive >=1
|
||||
, directory-tree >=0.12
|
||||
, esqueleto
|
||||
, filepath
|
||||
, hit >=0.6.3
|
||||
, json-state
|
||||
|
|
Loading…
Reference in a new issue