Provide a link to snapshot's changes

This commit is contained in:
Konstantin Zudov 2015-10-10 10:58:15 +03:00
parent 160f2b02f9
commit 1ab01273bc
3 changed files with 10 additions and 2 deletions

View File

@ -11,13 +11,13 @@ import qualified Data.HashMap.Strict as HashMap
import Data.These
import Data.Time (FormatTime)
import Stackage.Database
import Stackage.Database.Types (sortNicely)
import Stackage.Database.Types (sortNicely, previousSnapName)
import Stackage.Snapshot.Diff
getStackageHomeR :: SnapName -> Handler Html
getStackageHomeR name = do
Entity sid snapshot <- lookupSnapshot name >>= maybe notFound return
snapNames <- map snapshotName . snd <$> getSnapshots 0 0
let hoogleForm =
let queryText = "" :: Text
exact = False

View File

@ -1,6 +1,7 @@
module Stackage.Database.Types
( SnapName (..)
, sortNicely
, previousSnapName
) where
import ClassyPrelude.Conduit
@ -26,6 +27,10 @@ sortNicely :: [SnapName] -> [SnapName]
sortNicely ns = reverse (sort lts) ++ reverse (sort nightly)
where (lts, nightly) = partition isLTS ns
previousSnapName :: [SnapName] -> SnapName -> SnapName
previousSnapName ns n =
fromMaybe n $ maximumMay $ filter (< n) $ filter ((isLTS n ==) . isLTS) ns
instance PersistField SnapName where
toPersistValue = toPersistValue . toPathPiece
fromPersistValue v = do

View File

@ -5,6 +5,9 @@ $newline never
<p>
Published on #{yearMonthDay (snapshotCreated snapshot)}
<span .separator>
<span>
<a href=@{StackageDiffR (previousSnapName snapNames name) name}>View changes
<span .separator>
<span>
stack #
<code>resolver: #{toPathPiece name}