chore(status): improve readability of time spans
This commit is contained in:
parent
40dadd5876
commit
81721b0794
@ -6,6 +6,7 @@ module Handler.Health where
|
|||||||
|
|
||||||
import Import
|
import Import
|
||||||
|
|
||||||
|
import Data.Time.Format.ISO8601 (iso8601Show)
|
||||||
import Handler.Utils.DateTime (formatTimeW)
|
import Handler.Utils.DateTime (formatTimeW)
|
||||||
|
|
||||||
import qualified Data.Aeson.Encode.Pretty as Aeson
|
import qualified Data.Aeson.Encode.Pretty as Aeson
|
||||||
@ -77,12 +78,12 @@ getHealthR = do
|
|||||||
#{boolSymbol (healthOk hcstatus)} #
|
#{boolSymbol (healthOk hcstatus)} #
|
||||||
$case report
|
$case report
|
||||||
$of HealthLDAPAdmins (Just found)
|
$of HealthLDAPAdmins (Just found)
|
||||||
#{textPercent found 1}
|
#{textPercent found 1}
|
||||||
$of HealthActiveJobExecutors (Just active)
|
$of HealthActiveJobExecutors (Just active)
|
||||||
#{textPercent active 1}
|
#{textPercent active 1}
|
||||||
$of _
|
$of _
|
||||||
<div>
|
<div>
|
||||||
^{formatTimeW SelFormatDateTime lUp}
|
^{formatTimeW SelFormatDateTime lUp}
|
||||||
|]
|
|]
|
||||||
provideJson healthReports
|
provideJson healthReports
|
||||||
provideRep . return . Builder.toLazyText $ Aeson.encodePrettyToTextBuilder healthReports
|
provideRep . return . Builder.toLazyText $ Aeson.encodePrettyToTextBuilder healthReports
|
||||||
@ -115,32 +116,31 @@ getStatusR = do
|
|||||||
starttime <- getsYesod appStartTime
|
starttime <- getsYesod appStartTime
|
||||||
(currtime, env_version) <- liftIO $ (,) <$> getCurrentTime <*> lookupEnv "VERSION_NR"
|
(currtime, env_version) <- liftIO $ (,) <$> getCurrentTime <*> lookupEnv "VERSION_NR"
|
||||||
-- ft <- formatTime' "%Y-%m-%d %H:%M:%S" currtime
|
-- ft <- formatTime' "%Y-%m-%d %H:%M:%S" currtime
|
||||||
withUrlRenderer
|
let diffTime :: UTCTime -> Text
|
||||||
|
diffTime = pack . iso8601Show . calendarTimeTime . fromIntegral . truncate . diffUTCTime currtime
|
||||||
|
withUrlRenderer
|
||||||
[hamlet|
|
[hamlet|
|
||||||
$doctype 5
|
$doctype 5
|
||||||
<html lang=en>
|
<html lang=en>
|
||||||
<head>
|
<head>
|
||||||
<title>Status
|
<title>Status
|
||||||
<body>
|
<body>
|
||||||
$maybe env_ver <- env_version
|
$maybe env_ver <- env_version
|
||||||
<p>
|
<p>
|
||||||
Environment version #{env_ver}
|
Environment version #{env_ver}
|
||||||
<p>
|
|
||||||
Current Time <br>
|
|
||||||
#{show currtime} <br>
|
|
||||||
<p>
|
<p>
|
||||||
Instance Start <br>
|
Current Time <br>
|
||||||
|
#{show currtime} <br>
|
||||||
|
<p>
|
||||||
|
Instance Start <br>
|
||||||
#{show starttime} #
|
#{show starttime} #
|
||||||
Uptime: #{show $ ddays starttime currtime} days.
|
Uptime: #{diffTime starttime}
|
||||||
<p>
|
<p>
|
||||||
Compile Time <br>
|
Compile Time <br>
|
||||||
#{show cTime} #
|
#{show cTime} #
|
||||||
Build age: #{show $ ddays cTime currtime} days.
|
Build age: #{diffTime cTime}
|
||||||
|]
|
|]
|
||||||
where
|
where
|
||||||
-- vnr_full :: Text = $(embedStringFile "nix/docker/version.json") -- nix/ files not accessible during container construction
|
-- vnr_full :: Text = $(embedStringFile "nix/docker/version.json") -- nix/ files not accessible during container construction
|
||||||
cTime :: UTCTime
|
cTime :: UTCTime
|
||||||
cTime = $compileTime
|
cTime = $compileTime
|
||||||
|
|
||||||
ddays :: UTCTime -> UTCTime -> Double
|
|
||||||
ddays tstart tstop = (/100) $ fromIntegral $ round $ diffUTCTime tstop tstart / (36 * 24)
|
|
||||||
Reference in New Issue
Block a user