mirror of
https://github.com/commercialhaskell/stackage-server.git
synced 2026-01-18 07:01:55 +01:00
Get rid of hours display in date diffs (fixes #217)
Pinging @chrisdone and @juhp
This commit is contained in:
parent
bcf86a1d40
commit
e5a7e9b2e8
@ -8,8 +8,6 @@ module Handler.Home
|
|||||||
) where
|
) where
|
||||||
|
|
||||||
import Data.Time.Clock
|
import Data.Time.Clock
|
||||||
import Formatting
|
|
||||||
import Formatting.Time
|
|
||||||
import Import
|
import Import
|
||||||
import Stackage.Database
|
import Stackage.Database
|
||||||
import Yesod.GitRepo (grContent)
|
import Yesod.GitRepo (grContent)
|
||||||
@ -38,10 +36,7 @@ getHomeR = track "Handler.Snapshots.getAllSnapshotsR" $ do
|
|||||||
where uncrapify now' snapshot =
|
where uncrapify now' snapshot =
|
||||||
( snapshotName snapshot
|
( snapshotName snapshot
|
||||||
, snapshotTitle snapshot
|
, snapshotTitle snapshot
|
||||||
, format (diff True)
|
, dateDiff now' (snapshotCreated snapshot)
|
||||||
$ diffUTCTime
|
|
||||||
(UTCTime (snapshotCreated snapshot) 0)
|
|
||||||
now'
|
|
||||||
)
|
)
|
||||||
groupUp now' = groupBy (on (==) (\(_,_,uploaded) -> uploaded))
|
groupUp now' = groupBy (on (==) (\(_,_,uploaded) -> uploaded))
|
||||||
. map (uncrapify now')
|
. map (uncrapify now')
|
||||||
|
|||||||
@ -3,8 +3,6 @@
|
|||||||
module Handler.Snapshots where
|
module Handler.Snapshots where
|
||||||
|
|
||||||
import Data.Time.Clock
|
import Data.Time.Clock
|
||||||
import Formatting
|
|
||||||
import Formatting.Time
|
|
||||||
import Import
|
import Import
|
||||||
import Stackage.Database
|
import Stackage.Database
|
||||||
|
|
||||||
@ -40,10 +38,7 @@ getAllSnapshotsR = track "Handler.Snapshots.getAllSnapshotsR" $ do
|
|||||||
where uncrapify now' snapshot =
|
where uncrapify now' snapshot =
|
||||||
( snapshotName snapshot
|
( snapshotName snapshot
|
||||||
, snapshotTitle snapshot
|
, snapshotTitle snapshot
|
||||||
, format (diff True)
|
, dateDiff now' (snapshotCreated snapshot)
|
||||||
$ diffUTCTime
|
|
||||||
(UTCTime (snapshotCreated snapshot) 0)
|
|
||||||
now'
|
|
||||||
)
|
)
|
||||||
groupUp now' = groupBy (on (==) (\(_,_,uploaded) -> uploaded))
|
groupUp now' = groupBy (on (==) (\(_,_,uploaded) -> uploaded))
|
||||||
. map (uncrapify now')
|
. map (uncrapify now')
|
||||||
|
|||||||
11
Import.hs
11
Import.hs
@ -13,6 +13,8 @@ import Data.Text.Read (decimal)
|
|||||||
import Data.Time.Clock (diffUTCTime)
|
import Data.Time.Clock (diffUTCTime)
|
||||||
import qualified Prometheus as P
|
import qualified Prometheus as P
|
||||||
import Stackage.Database (SnapName)
|
import Stackage.Database (SnapName)
|
||||||
|
import Formatting (format)
|
||||||
|
import Formatting.Time (diff)
|
||||||
|
|
||||||
parseLtsPair :: Text -> Maybe (Int, Int)
|
parseLtsPair :: Text -> Maybe (Int, Int)
|
||||||
parseLtsPair t1 = do
|
parseLtsPair t1 = do
|
||||||
@ -60,3 +62,12 @@ track name inner = do
|
|||||||
"stackage_server_fn"
|
"stackage_server_fn"
|
||||||
"Stackage Server function call (duration in microseconds).")
|
"Stackage Server function call (duration in microseconds).")
|
||||||
P.defaultQuantiles))
|
P.defaultQuantiles))
|
||||||
|
|
||||||
|
dateDiff :: UTCTime -- ^ now
|
||||||
|
-> Day -- ^ target
|
||||||
|
-> LText
|
||||||
|
dateDiff (UTCTime now' _) target
|
||||||
|
| now' == target = "today"
|
||||||
|
| otherwise = format (diff True) $ diffUTCTime
|
||||||
|
(UTCTime target 0)
|
||||||
|
(UTCTime now' 0)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user