Insert dummy data to see results

This commit is contained in:
fr33domlover 2016-02-11 22:19:31 +00:00
parent 552b17e219
commit 229bdead0e

View file

@ -31,7 +31,7 @@ where
import Control.Monad.IO.Class (liftIO)
import Data.Text (Text)
import Database.Esqueleto ((^.), (&&.), (==.))
--import Database.Persist hiding ((==.))
import Database.Persist hiding ((==.))
import Database.Persist.Sqlite hiding ((==.))
import Database.Persist.TH
@ -88,6 +88,34 @@ PersonInGroup
mainViewQuery :: IO ()
mainViewQuery = runSqlite ":memory:" $ do
runMigration migrateAll
--create some sharers
cindyId <- insert $ Sharer "cindy" Nothing
bobId <- insert $ Sharer "bob" Nothing
aliceId <- insert $ Sharer "alice" Nothing
--create some projects
proj4Id <- insert $ Project "proj4" cindyId Nothing Nothing
proj2Id <- insert $ Project "proj2" aliceId Nothing Nothing
proj6Id <- insert $ Project "proj6" cindyId Nothing Nothing
proj3Id <- insert $ Project "proj3" bobId Nothing Nothing
proj5Id <- insert $ Project "proj5" cindyId Nothing Nothing
proj1Id <- insert $ Project "proj1" aliceId Nothing Nothing
--create some repos
insert_ $ Repo "repo8" proj5Id Nothing Nothing
insert_ $ Repo "repo1" proj1Id Nothing Nothing
insert_ $ Repo "repo6" proj4Id Nothing Nothing
insert_ $ Repo "repo3" proj3Id Nothing Nothing
insert_ $ Repo "repo4" proj3Id Nothing Nothing
insert_ $ Repo "repo10" proj6Id Nothing Nothing
insert_ $ Repo "repo5" proj4Id Nothing Nothing
insert_ $ Repo "repo7" proj5Id Nothing Nothing
insert_ $ Repo "repo2" proj2Id Nothing Nothing
insert_ $ Repo "repo9" proj5Id Nothing Nothing
insert_ $ Repo "repo11" proj6Id Nothing Nothing
insert_ $ Repo "repo12" proj6Id Nothing Nothing
rows <- E.select $ E.from $ \ (sharer, project, repo) -> do
E.where_ $
project ^. ProjectSharer ==. sharer ^. SharerId &&.