Banned tags #34

This commit is contained in:
Michael Snoyman 2014-11-20 12:26:45 +02:00
parent fe4cda60f8
commit 985f48a6dc
3 changed files with 16 additions and 4 deletions

View File

@ -45,9 +45,13 @@ getPackageR pn = do
tags <- fmap (map (\(E.Value v) -> v))
(runDB (E.selectDistinct
(E.from (\t -> do E.where_ (t ^. TagPackage E.==. E.val pn)
E.orderBy [E.asc (t ^. TagTag)]
return (t ^. TagTag)))))
(E.from (\(t `E.LeftOuterJoin` bt) -> do
E.on $ t E.^. TagTag E.==. bt E.^. BannedTagTag
E.where_
$ (t ^. TagPackage E.==. E.val pn) E.&&.
(E.isNothing $ E.just $ bt E.^. BannedTagTag)
E.orderBy [E.asc (t ^. TagTag)]
return (t ^. TagTag)))))
let likeTitle = if liked
then "You liked this!"

View File

@ -8,9 +8,11 @@ import Import
getTagListR :: Handler Html
getTagListR = do
tags <- fmap (zip [0::Int ..] . (map (\(E.Value v,E.Value i) -> (v,i::Int)))) $ runDB $
E.select $ E.from $ \tag -> do
E.select $ E.from $ \(tag `E.LeftOuterJoin` bt) -> do
E.groupBy (tag E.^. TagTag)
E.orderBy [E.desc (E.count (tag E.^. TagTag) :: E.SqlExpr (E.Value Int))]
E.on $ tag E.^. TagTag E.==. bt E.^. BannedTagTag
E.where_ $ E.isNothing $ E.just $ bt E.^. BannedTagTag
return (tag E.^. TagTag, E.count (tag E.^. TagTag))
defaultLayout $ do
setTitle "Stackage tags"
@ -18,6 +20,8 @@ getTagListR = do
getTagR :: Slug -> Handler Html
getTagR tagSlug = do
-- 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.
packages <- fmap (map (\(E.Value t,E.Value s) -> (t,strip s))) $ runDB $
E.select $ E.from $ \(tag,meta) -> do
E.where_ (tag E.^. TagTag E.==. E.val tagSlug E.&&.

View File

@ -84,3 +84,7 @@ Metadata
licenseContent Html Maybe
UniqueMetadata name
BannedTag
tag Slug
UniqueBannedTag tag