mirror of
https://code.sup39.dev/repos/Wqawg
synced 2024-12-29 01:04:52 +09:00
Replace some Esqueleto with much simpler Persistent queries
This commit is contained in:
parent
b20c672a01
commit
9afd341aca
4 changed files with 49 additions and 60 deletions
|
@ -87,14 +87,10 @@ getPersonNewR = do
|
||||||
|
|
||||||
getPersonR :: Text -> Handler Html
|
getPersonR :: Text -> Handler Html
|
||||||
getPersonR ident = do
|
getPersonR ident = do
|
||||||
people <- runDB $ select $ from $ \ (sharer, person) -> do
|
person <- runDB $ do
|
||||||
where_ $
|
Entity sid _s <- getBy404 $ UniqueSharerIdent ident
|
||||||
sharer ^. SharerIdent ==. val ident &&.
|
Entity _pid p <- getBy404 $ UniquePersonIdent sid
|
||||||
sharer ^. SharerId ==. person ^. PersonIdent
|
return p
|
||||||
return person
|
defaultLayout $ do
|
||||||
case people of
|
|
||||||
[] -> notFound
|
|
||||||
p:ps -> defaultLayout $ do
|
|
||||||
let mperson = if null ps then Just p else Nothing
|
|
||||||
setTitle $ text $ "Vervis > People > " <> ident
|
setTitle $ text $ "Vervis > People > " <> ident
|
||||||
$(widgetFile "person")
|
$(widgetFile "person")
|
||||||
|
|
|
@ -72,16 +72,11 @@ getProjectNewR ident = do
|
||||||
|
|
||||||
getProjectR :: Text -> Text -> Handler Html
|
getProjectR :: Text -> Text -> Handler Html
|
||||||
getProjectR user proj = do
|
getProjectR user proj = do
|
||||||
projects <- runDB $ select $ from $ \ (sharer, project) -> do
|
project <- runDB $ do
|
||||||
where_ $
|
Entity sid _s <- getBy404 $ UniqueSharerIdent user
|
||||||
sharer ^. SharerIdent ==. val user &&.
|
Entity _pid p <- getBy404 $ UniqueProject proj sid
|
||||||
project ^. ProjectIdent ==. val proj &&.
|
return p
|
||||||
sharer ^. SharerId ==. project ^. ProjectSharer
|
defaultLayout $ do
|
||||||
return project
|
|
||||||
case projects of
|
|
||||||
[] -> notFound
|
|
||||||
p:ps -> defaultLayout $ do
|
|
||||||
let mproject = if null ps then Just p else Nothing
|
|
||||||
setTitle $ text $ mconcat
|
setTitle $ text $ mconcat
|
||||||
[ "Vervis > People > "
|
[ "Vervis > People > "
|
||||||
, user
|
, user
|
||||||
|
|
|
@ -14,15 +14,11 @@ $# <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||||
|
|
||||||
<h1>Vervis > People > #{ident}
|
<h1>Vervis > People > #{ident}
|
||||||
|
|
||||||
$maybe Entity _pid _person <- mperson
|
<h2>About
|
||||||
<h2>About
|
<p>
|
||||||
<p>
|
|
||||||
This is the user page for <b>#{ident}</b>
|
This is the user page for <b>#{ident}</b>
|
||||||
|
|
||||||
<h2>Projects
|
<h2>Projects
|
||||||
<p>
|
<p>
|
||||||
See
|
See
|
||||||
<a href=@{ProjectsR ident}>projects</a>.
|
<a href=@{ProjectsR ident}>projects</a>.
|
||||||
|
|
||||||
$nothing
|
|
||||||
<p>Internal error: More than one user with the same identifier!
|
|
||||||
|
|
|
@ -14,12 +14,11 @@ $# <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||||
|
|
||||||
<h1>Vervis > People > #{user} > Projects > #{proj}
|
<h1>Vervis > People > #{user} > Projects > #{proj}
|
||||||
|
|
||||||
$maybe Entity _pid project <- mproject
|
<h2>About
|
||||||
<h2>About
|
<p>This is the project page for <b>#{proj}</b>, shared by <b>#{user}</b>.
|
||||||
<p>This is the project page for <b>#{proj}</b>, shared by <b>#{user}</b>.
|
|
||||||
|
|
||||||
<h2>Details
|
<h2>Details
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Human-friendly name
|
<td>Human-friendly name
|
||||||
<td>
|
<td>
|
||||||
|
@ -35,5 +34,8 @@ $maybe Entity _pid project <- mproject
|
||||||
$nothing
|
$nothing
|
||||||
(none)
|
(none)
|
||||||
|
|
||||||
$nothing
|
<h2>Repos
|
||||||
<p>Internal error: More than one project per user/proj name pair!
|
|
||||||
|
<p>
|
||||||
|
See
|
||||||
|
<a href=@{ReposR user proj}>repos</a>.
|
||||||
|
|
Loading…
Reference in a new issue