Skip to content

Commit ea90734

Browse files
committed
stackage-diff: add a previous diff link
allowing navigating back to earlier consecutive diffs Arguably we could also navigate name1 and name2 separately
1 parent ec5d5e7 commit ea90734

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/Handler/StackageHome.hs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ module Handler.StackageHome
1212
, getSnapshotPackagesR
1313
) where
1414

15+
import Data.Maybe (fromJust)
1516
import Data.These
1617
import RIO (textDisplay)
1718
import RIO.Time (FormatTime)
@@ -53,7 +54,8 @@ instance ToJSON SnapshotInfo where
5354
getStackageDiffR :: SnapName -> SnapName -> Handler TypedContent
5455
getStackageDiffR name1 name2 = track "Handler.StackageHome.getStackageDiffR" $ do
5556
cacheSeconds $ 60 * 60 * 48
56-
Entity sid1 _ <- lookupSnapshot name1 >>= maybe notFound return
57+
Entity sid1 prevSnap <- lookupSnapshot name1 >>= maybe notFound return
58+
mprevprevSnapName <- map snd <$> snapshotBefore (snapshotName prevSnap)
5759
Entity sid2 _ <- lookupSnapshot name2 >>= maybe notFound return
5860
snapDiff <- getSnapshotDiff sid1 sid2
5961
selectRep $ do

templates/stackage-diff.hamlet

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
<h1>Compare Stackage snapshots
22

3+
$if isJust mprevprevSnapName
4+
<div .snapshot-nav>
5+
<a href=@{StackageDiffR (fromJust mprevprevSnapName) name1}>
6+
\< previous diff
7+
38
<div .container .content>
49
<div .packages>
510
<table .table>

0 commit comments

Comments
 (0)