Add /feed/#LtsMajor (e.g /feed/lts-3)
This commit is contained in:
parent
8c9c916491
commit
5c2e8ecf68
3 changed files with 24 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
|||
module Handler.Feed
|
||||
( getFeedR
|
||||
, getLtsFeedR
|
||||
, getLtsMajorFeedR
|
||||
, getNightlyFeedR
|
||||
) where
|
||||
|
||||
|
@ -16,10 +17,14 @@ getFeedR = mkFeed . snd =<< getSnapshots 20 0
|
|||
getLtsFeedR :: Handler TypedContent
|
||||
getLtsFeedR = mkFeed . snd =<< getLtsSnapshots 20 0
|
||||
|
||||
getLtsMajorFeedR :: LtsMajor -> Handler TypedContent
|
||||
getLtsMajorFeedR (LtsMajor v) = mkFeed . snd =<< getLtsMajorSnapshots v 20 0
|
||||
|
||||
getNightlyFeedR :: Handler TypedContent
|
||||
getNightlyFeedR = mkFeed . snd =<< getNightlySnapshots 20 0
|
||||
|
||||
mkFeed :: [Entity Snapshot] -> Handler TypedContent
|
||||
mkFeed [] = notFound
|
||||
mkFeed snaps = do
|
||||
entries <- forM snaps $ \(Entity snapid snap) -> do
|
||||
content <- getContent snapid snap
|
||||
|
|
|
@ -34,6 +34,7 @@ module Stackage.Database
|
|||
, getSnapshotsForPackage
|
||||
, getSnapshots
|
||||
, getLtsSnapshots
|
||||
, getLtsMajorSnapshots
|
||||
, getNightlySnapshots
|
||||
, currentSchema
|
||||
, last5Lts5Nightly
|
||||
|
@ -684,6 +685,23 @@ getLtsSnapshots l o = run $ do
|
|||
return snapshot
|
||||
return (ltsCount, snapshots)
|
||||
|
||||
getLtsMajorSnapshots :: GetStackageDatabase m
|
||||
=> Int -- ^ Major version
|
||||
-> Int -- ^ limit
|
||||
-> Int -- ^ offset
|
||||
-> m (Int, [Entity Snapshot])
|
||||
getLtsMajorSnapshots v l o = run $ do
|
||||
ltsCount <- count ([] :: [Filter Lts])
|
||||
snapshots <- E.select $ E.from $
|
||||
\(lts `E.InnerJoin` snapshot) -> do
|
||||
E.on $ lts E.^. LtsSnap E.==. snapshot E.^. SnapshotId
|
||||
E.orderBy [E.desc (lts E.^. LtsMinor)]
|
||||
E.where_ ((lts E.^. LtsMajor) E.==. (E.val v))
|
||||
E.limit $ fromIntegral l
|
||||
E.offset $ fromIntegral o
|
||||
return snapshot
|
||||
return (ltsCount, snapshots)
|
||||
|
||||
getNightlySnapshots :: GetStackageDatabase m
|
||||
=> Int -- ^ limit
|
||||
-> Int -- ^ offset
|
||||
|
|
|
@ -47,5 +47,6 @@
|
|||
/download/#SupportedArch/#Text DownloadGhcLinksR GET
|
||||
|
||||
/feed FeedR GET
|
||||
!/feed/#LtsMajor LtsMajorFeedR GET
|
||||
/feed/lts LtsFeedR GET
|
||||
/feed/nightly NightlyFeedR GET
|
||||
|
|
Loading…
Reference in a new issue