diff --git a/src/Handler/Health.hs b/src/Handler/Health.hs index e06f688ae..69db731e1 100644 --- a/src/Handler/Health.hs +++ b/src/Handler/Health.hs @@ -6,6 +6,7 @@ module Handler.Health where import Import +import Data.Time.Format.ISO8601 (iso8601Show) import Handler.Utils.DateTime (formatTimeW) import qualified Data.Aeson.Encode.Pretty as Aeson @@ -77,12 +78,12 @@ getHealthR = do #{boolSymbol (healthOk hcstatus)} # $case report $of HealthLDAPAdmins (Just found) - #{textPercent found 1} + #{textPercent found 1} $of HealthActiveJobExecutors (Just active) #{textPercent active 1} $of _
- ^{formatTimeW SelFormatDateTime lUp} + ^{formatTimeW SelFormatDateTime lUp} |] provideJson healthReports provideRep . return . Builder.toLazyText $ Aeson.encodePrettyToTextBuilder healthReports @@ -115,32 +116,31 @@ getStatusR = do starttime <- getsYesod appStartTime (currtime, env_version) <- liftIO $ (,) <$> getCurrentTime <*> lookupEnv "VERSION_NR" -- ft <- formatTime' "%Y-%m-%d %H:%M:%S" currtime - withUrlRenderer + let diffTime :: UTCTime -> Text + diffTime = pack . iso8601Show . calendarTimeTime . fromIntegral . truncate . diffUTCTime currtime + withUrlRenderer [hamlet| $doctype 5 - + Status <body> $maybe env_ver <- env_version <p> Environment version #{env_ver} - <p> - Current Time <br> - #{show currtime} <br> <p> - Instance Start <br> + Current Time <br> + #{show currtime} <br> + <p> + Instance Start <br> #{show starttime} # - Uptime: #{show $ ddays starttime currtime} days. + Uptime: #{diffTime starttime} <p> Compile Time <br> #{show cTime} # - Build age: #{show $ ddays cTime currtime} days. + Build age: #{diffTime cTime} |] - where - -- vnr_full :: Text = $(embedStringFile "nix/docker/version.json") -- nix/ files not accessible during container construction + where + -- vnr_full :: Text = $(embedStringFile "nix/docker/version.json") -- nix/ files not accessible during container construction cTime :: UTCTime - cTime = $compileTime - - ddays :: UTCTime -> UTCTime -> Double - ddays tstart tstop = (/100) $ fromIntegral $ round $ diffUTCTime tstop tstart / (36 * 24) + cTime = $compileTime \ No newline at end of file