mirror of
https://github.com/commercialhaskell/stackage-server.git
synced 2026-02-06 08:07:28 +01:00
Add /package-counts
This commit is contained in:
parent
dc773eef0a
commit
af28229971
@ -71,6 +71,7 @@ import Handler.BannedTags
|
|||||||
import Handler.RefreshDeprecated
|
import Handler.RefreshDeprecated
|
||||||
import Handler.Hoogle
|
import Handler.Hoogle
|
||||||
import Handler.BuildVersion
|
import Handler.BuildVersion
|
||||||
|
import Handler.PackageCounts
|
||||||
|
|
||||||
-- This line actually creates our YesodDispatch instance. It is the second half
|
-- This line actually creates our YesodDispatch instance. It is the second half
|
||||||
-- of the call to mkYesodData which occurs in Foundation.hs. Please see the
|
-- of the call to mkYesodData which occurs in Foundation.hs. Please see the
|
||||||
|
|||||||
39
Handler/PackageCounts.hs
Normal file
39
Handler/PackageCounts.hs
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
module Handler.PackageCounts
|
||||||
|
( getPackageCountsR
|
||||||
|
) where
|
||||||
|
|
||||||
|
import Import hiding (Value (..), groupBy, (==.))
|
||||||
|
import Data.Slug (mkSlug)
|
||||||
|
import Database.Esqueleto
|
||||||
|
|
||||||
|
data Count = Count
|
||||||
|
{ name :: Text
|
||||||
|
, date :: Day
|
||||||
|
, packages :: Int
|
||||||
|
}
|
||||||
|
|
||||||
|
toCount :: (Value Text, Value UTCTime, Value Int) -> Count
|
||||||
|
toCount (Value x, Value y, Value z) =
|
||||||
|
Count x (utctDay y) z
|
||||||
|
|
||||||
|
getPackageCountsR :: Handler Html
|
||||||
|
getPackageCountsR = do
|
||||||
|
admins <- adminUsers <$> getExtra
|
||||||
|
counts <- runDB $ do
|
||||||
|
let slugs = mapMaybe mkSlug $ setToList admins
|
||||||
|
adminUids <- selectKeysList [UserHandle <-. slugs] []
|
||||||
|
fmap (map toCount) $ select $ from $ \(s, p) -> do
|
||||||
|
where_ $
|
||||||
|
(not_ $ s ^. StackageTitle `like` val "%inclusive") &&.
|
||||||
|
(s ^. StackageId ==. p ^. PackageStackage) &&.
|
||||||
|
(s ^. StackageUser `in_` valList adminUids)
|
||||||
|
groupBy (s ^. StackageTitle, s ^. StackageUploaded)
|
||||||
|
orderBy [desc $ s ^. StackageUploaded]
|
||||||
|
return
|
||||||
|
( s ^. StackageTitle
|
||||||
|
, s ^. StackageUploaded
|
||||||
|
, countRows
|
||||||
|
)
|
||||||
|
defaultLayout $ do
|
||||||
|
setTitle "Package counts"
|
||||||
|
$(widgetFile "package-counts")
|
||||||
@ -55,3 +55,4 @@
|
|||||||
|
|
||||||
/refresh-deprecated RefreshDeprecatedR GET
|
/refresh-deprecated RefreshDeprecatedR GET
|
||||||
/build-version BuildVersionR GET
|
/build-version BuildVersionR GET
|
||||||
|
/package-counts PackageCountsR GET
|
||||||
|
|||||||
@ -54,6 +54,7 @@ library
|
|||||||
Handler.BannedTags
|
Handler.BannedTags
|
||||||
Handler.RefreshDeprecated
|
Handler.RefreshDeprecated
|
||||||
Handler.BuildVersion
|
Handler.BuildVersion
|
||||||
|
Handler.PackageCounts
|
||||||
|
|
||||||
if flag(dev) || flag(library-only)
|
if flag(dev) || flag(library-only)
|
||||||
cpp-options: -DDEVELOPMENT
|
cpp-options: -DDEVELOPMENT
|
||||||
|
|||||||
20
templates/package-counts.hamlet
Normal file
20
templates/package-counts.hamlet
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<div .container>
|
||||||
|
<h1>Package counts
|
||||||
|
|
||||||
|
<p>
|
||||||
|
This page provides historical information on the number of packages included
|
||||||
|
in Stackage Nightly and LTS Haskell snapshots, purely for the sake of
|
||||||
|
curiosity.
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th .name>Title
|
||||||
|
<th .count>Count
|
||||||
|
<th .date>Date
|
||||||
|
<tbody>
|
||||||
|
$forall c <- counts
|
||||||
|
<tr>
|
||||||
|
<td .name>#{name c}
|
||||||
|
<td .count>#{packages c}
|
||||||
|
<td .date>#{show $ date c}
|
||||||
12
templates/package-counts.lucius
Normal file
12
templates/package-counts.lucius
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
th {
|
||||||
|
font-size: 1.2em;
|
||||||
|
}
|
||||||
|
|
||||||
|
td, th {
|
||||||
|
padding: 0.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.name {
|
||||||
|
text-align: right;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user