Include latest LTS by GHC version (fixes #210)

This commit is contained in:
Michael Snoyman 2016-11-07 07:26:07 +02:00
parent ef8171bb94
commit 58c4e6c163
3 changed files with 21 additions and 0 deletions

View File

@ -31,6 +31,7 @@ getHomeR = track "Handler.Snapshots.getAllSnapshotsR" $ do
getSnapshots Nothing snapshotsPerPage
((fromIntegral currentPage - 1) * snapshotsPerPage)
let groups = groupUp now' snapshots
latestLtsByGhc <- getLatestLtsByGhc
defaultLayout $ do
setTitle "Stackage Server"
$(widgetFile "home")

View File

@ -39,6 +39,7 @@ module Stackage.Database
, last5Lts5Nightly
, snapshotsJSON
, getPackageCount
, getLatestLtsByGhc
) where
import Database.Sqlite (SqliteException)
@ -783,3 +784,15 @@ getPackageCount :: GetStackageDatabase m
=> SnapshotId
-> m Int
getPackageCount sid = run $ count [SnapshotPackageSnapshot ==. sid]
getLatestLtsByGhc :: GetStackageDatabase m
=> m [(Int, Int, Text)]
getLatestLtsByGhc = run $ fmap (map toTuple) $ do
E.select $ E.from $ \(lts `E.InnerJoin` snapshot) -> do
E.on $ lts E.^. LtsSnap E.==. snapshot E.^. SnapshotId
E.orderBy [E.desc (lts E.^. LtsMajor), E.desc (lts E.^. LtsMinor)]
E.groupBy (snapshot E.^. SnapshotGhc)
return (lts, snapshot)
where
toTuple (Entity _ lts, Entity _ snapshot) =
(ltsMajor lts, ltsMinor lts, snapshotGhc snapshot)

View File

@ -46,6 +46,13 @@
on
<a href="https://haskell-lang.org/">
haskell-lang.org
<h3>
Latest LTS per GHC version
<ul>
$forall (major, minor, ghc) <- latestLtsByGhc
<li>
<a href=@{SnapshotR (SNLts major minor) StackageHomeR}>LTS #{major}.#{minor} for GHC #{ghc}
<div .span6>
<h3>Snapshots
$forall stackages <- groups