mirror of
https://github.com/commercialhaskell/stackage-server.git
synced 2026-01-24 18:01:57 +01:00
Try to fix #277 by deleting verbose info
Problem ==== Too slow response from stackage.org/feed/. So slow that my favorite RSS client (Slack's RSS integration) doesn't work due to timeout. See https://github.com/fpco/stackage-server/issues/277 for details. How? ==== Delete the content of the feed if stackage.org/feed is given `withDiff=False` as its query parameter. Why? ==== I can't confirm it's the true cause of the slowdown (because the server is too hard to run on my machine!). But anyway I think the html content of the feed is too much: I just want to know the new LTS Haskell is released by the feed. I'll click the link if I do want to see the detailed updates. In addition, there's a reason generating the content causes the slowdown: Other pages using `getSnapshots` (e.g. https://www.stackage.org/snapshots, https://www.stackage.org/) are not as slow as https://www.stackage.org/feed/. So the `getSnapshots` query dosen't seem to be the biggest cause. And the left possible cause is `mkFeed`. NOTE ==== I've tested nothing because it's too hard to run this app without configuring my AWS account.
This commit is contained in:
parent
f3ee682725
commit
cc7b12dcd7
@ -1,3 +1,4 @@
|
|||||||
|
{-# LANGUAGE LambdaCase #-}
|
||||||
{-# LANGUAGE NoImplicitPrelude #-}
|
{-# LANGUAGE NoImplicitPrelude #-}
|
||||||
{-# LANGUAGE QuasiQuotes #-}
|
{-# LANGUAGE QuasiQuotes #-}
|
||||||
module Handler.Feed
|
module Handler.Feed
|
||||||
@ -7,10 +8,11 @@ module Handler.Feed
|
|||||||
|
|
||||||
import Data.These
|
import Data.These
|
||||||
import Import
|
import Import
|
||||||
|
import RIO.Time (getCurrentTime)
|
||||||
import Stackage.Database
|
import Stackage.Database
|
||||||
import Stackage.Snapshot.Diff
|
import Stackage.Snapshot.Diff
|
||||||
import Text.Blaze (text)
|
import Text.Blaze (text)
|
||||||
import RIO.Time (getCurrentTime)
|
import Yesod.Core.Handler (lookupGetParam)
|
||||||
|
|
||||||
getFeedR :: Handler TypedContent
|
getFeedR :: Handler TypedContent
|
||||||
getFeedR = track "Handler.Feed.getBranchFeedR" $ getBranchFeed Nothing
|
getFeedR = track "Handler.Feed.getBranchFeedR" $ getBranchFeed Nothing
|
||||||
@ -25,7 +27,11 @@ mkFeed :: Maybe SnapshotBranch -> [Entity Snapshot] -> Handler TypedContent
|
|||||||
mkFeed _ [] = notFound
|
mkFeed _ [] = notFound
|
||||||
mkFeed mBranch snaps = do
|
mkFeed mBranch snaps = do
|
||||||
entries <- forM snaps $ \(Entity snapid snap) -> do
|
entries <- forM snaps $ \(Entity snapid snap) -> do
|
||||||
content <- getContent snapid snap
|
showsDiff <- doesShowDiff
|
||||||
|
content <-
|
||||||
|
if showsDiff
|
||||||
|
then getContent snapid snap
|
||||||
|
else return mempty
|
||||||
return FeedEntry
|
return FeedEntry
|
||||||
{ feedEntryLink = SnapshotR (snapshotName snap) StackageHomeR
|
{ feedEntryLink = SnapshotR (snapshotName snap) StackageHomeR
|
||||||
, feedEntryUpdated = UTCTime (snapshotCreated snap) 0
|
, feedEntryUpdated = UTCTime (snapshotCreated snap) 0
|
||||||
@ -54,6 +60,14 @@ mkFeed mBranch snaps = do
|
|||||||
branchTitle (LtsMajorBranch x) = "LTS-" <> tshow x
|
branchTitle (LtsMajorBranch x) = "LTS-" <> tshow x
|
||||||
title = "Recent Stackage " <> maybe "" branchTitle mBranch <> " snapshots"
|
title = "Recent Stackage " <> maybe "" branchTitle mBranch <> " snapshots"
|
||||||
|
|
||||||
|
doesShowDiff =
|
||||||
|
(fmap fromPathPiece <$> lookupGetParam "withDiff") >>= \case
|
||||||
|
Just (Just False) -> return False
|
||||||
|
Just (Just True) -> return True
|
||||||
|
Just Nothing -> notFound
|
||||||
|
Nothing -> return True
|
||||||
|
|
||||||
|
|
||||||
getContent :: SnapshotId -> Snapshot -> Handler Html
|
getContent :: SnapshotId -> Snapshot -> Handler Html
|
||||||
getContent sid2 snap = do
|
getContent sid2 snap = do
|
||||||
mprev <- snapshotBefore $ snapshotName snap
|
mprev <- snapshotBefore $ snapshotName snap
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user