Avoid duplicate packages on tag page (fixes #116)

This commit is contained in:
Michael Snoyman 2015-08-13 21:40:04 +03:00
parent c0b3ea9302
commit bb01d34d8c

View File

@ -22,9 +22,12 @@ getTagR :: Slug -> Handler Html
getTagR tagSlug = do getTagR tagSlug = do
-- FIXME arguably: check if this tag is banned. Leaving it as displayed for -- FIXME arguably: check if this tag is banned. Leaving it as displayed for
-- now, since someone needs to go out of their way to find it. -- now, since someone needs to go out of their way to find it.
tags <- runDB $ selectList [TagTag ==. tagSlug] [Asc TagPackage] packages' <- runDB $ E.select $ E.from $ \tag -> do
packages <- fmap catMaybes $ forM tags $ \(Entity _ t) -> do E.groupBy (tag E.^. TagPackage)
let pname = tagPackage t E.where_ $ tag E.^. TagTag E.==. E.val tagSlug
E.orderBy [E.asc $ tag E.^. TagPackage]
return $ tag E.^. TagPackage
packages <- fmap catMaybes $ forM packages' $ \(E.Value pname) -> do
mp <- getPackage $ toPathPiece pname mp <- getPackage $ toPathPiece pname
return $ case mp of return $ case mp of
Nothing -> Nothing Nothing -> Nothing