Use getBy404

This commit is contained in:
Chris Done 2014-11-03 13:26:09 +01:00
parent f51e70c09e
commit d195dea789
2 changed files with 4 additions and 7 deletions

View File

@ -23,9 +23,7 @@ getPackageR pn = do
asInt = id
haddocksLink ident version =
HaddockR ident [concat [toPathPiece pn, "-", toPathPiece version]]
(latestVersion, packages, downloads, recentDownloads, Entity _ metadata) <- runDB $ do
mupload <- selectFirst [UploadedName ==. pn] [Desc UploadedUploaded]
Entity _ (Uploaded _ latestVersion _) <- maybe notFound return mupload
(packages, downloads, recentDownloads, Entity _ metadata) <- runDB $ do
packages <- fmap (map reformat) $ E.select $ E.from $ \(p, s) -> do
E.where_ $ (p ^. PackageStackage E.==. s ^. StackageId)
&&. (p ^. PackageName' E.==. E.val pn)
@ -38,9 +36,8 @@ getPackageR pn = do
now <- liftIO getCurrentTime
let nowMinus30 = addUTCTime (-30 * 24 * 60 * 60) now
recentDownloads <- count [DownloadPackage ==. pn, DownloadTimestamp >=. nowMinus30]
metadata <- fmap listToMaybe (selectList [MetadataName ==. pn] [LimitTo 1]) >>=
maybe notFound return
return (latestVersion, packages, downloads, recentDownloads, metadata)
metadata <- getBy404 (UniqueMetadata pn)
return (packages, downloads, recentDownloads, metadata)
readmeText <- return "TODO"
let readmeHtml = markdown def readmeText
deps = enumerate (metadataDeps metadata)

View File

@ -5,7 +5,7 @@ $newline never
<h1>
#{pn} #
<span .latest-version>
#{latestVersion} #
#{metadataVersion metadata} #
<small>
(current)
<div .row>