diff --git a/Handler/Tag.hs b/Handler/Tag.hs index 09087f0..8966dc5 100644 --- a/Handler/Tag.hs +++ b/Handler/Tag.hs @@ -7,10 +7,11 @@ import Import getTagListR :: Handler Html getTagListR = do - tags <- fmap (map (\(E.Value v) -> v)) $ runDB $ - E.selectDistinct $ E.from $ \tag -> do - E.orderBy [E.asc (tag E.^. TagTag)] - return (tag E.^. TagTag) + tags <- fmap (zip [0::Int ..] . (map (\(E.Value v,E.Value i) -> (v,i::Int)))) $ runDB $ + E.select $ E.from $ \tag -> do + E.groupBy (tag E.^. TagTag) + E.orderBy [E.desc (E.count (tag E.^. TagTag) :: E.SqlExpr (E.Value Int))] + return (tag E.^. TagTag, E.count (tag E.^. TagTag)) defaultLayout $ do setTitle "Stackage tags" $(widgetFile "tag-list") diff --git a/templates/tag-list.hamlet b/templates/tag-list.hamlet index c98e4f1..58c6432 100644 --- a/templates/tag-list.hamlet +++ b/templates/tag-list.hamlet @@ -1,7 +1,11 @@ +$newline never

Tags -