mirror of
https://github.com/commercialhaskell/stackage-server.git
synced 2026-01-11 19:58:28 +01:00
Display count for tags list/sort by that count (#26)
This commit is contained in:
parent
df66e5d982
commit
77a81b7a2f
@ -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")
|
||||
|
||||
@ -1,7 +1,11 @@
|
||||
$newline never
|
||||
<div .container>
|
||||
<h1>Tags
|
||||
<ul .tags>
|
||||
$forall tag <- tags
|
||||
<li>
|
||||
<p .tags>
|
||||
$forall (i,(tag,count)) <- tags
|
||||
$if i /= 0
|
||||
, #
|
||||
<span .tag>
|
||||
<a href=@{TagR tag}>
|
||||
#{tag}
|
||||
#{tag} #
|
||||
<span .count>(#{count})
|
||||
|
||||
@ -10,3 +10,7 @@
|
||||
h1 {
|
||||
margin-bottom: 0.5em;
|
||||
}
|
||||
|
||||
.count {
|
||||
color: #666;
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@ $newline never
|
||||
|
||||
<div .container>
|
||||
<h1>
|
||||
Packages tagged: #{tag} (
|
||||
Tag: #{tag} (
|
||||
<a href=@{TagListR}>
|
||||
all tags
|
||||
)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user