changes log epoch to use text instead of word64 due to overflow issues (#81)

This commit is contained in:
Keagan McClelland
2021-11-23 17:24:54 -07:00
parent a9c86685b5
commit ae2bc09b0f
2 changed files with 3 additions and 10 deletions

View File

@@ -2,11 +2,9 @@
{-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeApplications #-}
module Handler.ErrorLogs where module Handler.ErrorLogs where
import Control.Monad ( MonadFail(fail) )
import Data.Aeson ( (.:) import Data.Aeson ( (.:)
, FromJSON(parseJSON) , FromJSON(parseJSON)
, withObject , withObject
, withText
) )
import Foundation import Foundation
import Model ( EntityField(ErrorLogRecordIncidents) import Model ( EntityField(ErrorLogRecordIncidents)
@@ -20,7 +18,7 @@ import Yesod.Persist ( (+=.)
) )
data ErrorLog = ErrorLog data ErrorLog = ErrorLog
{ errorLogEpoch :: Word64 { errorLogEpoch :: Text
, errorLogCommitHash :: Text , errorLogCommitHash :: Text
, errorLogSourceFile :: Text , errorLogSourceFile :: Text
, errorLogLine :: Word32 , errorLogLine :: Word32
@@ -32,12 +30,7 @@ data ErrorLog = ErrorLog
instance FromJSON ErrorLog where instance FromJSON ErrorLog where
parseJSON = withObject "Error Log" $ \o -> do parseJSON = withObject "Error Log" $ \o -> do
errorLogEpoch <- o .: "log-epoch" >>= withText errorLogEpoch <- o .: "log-epoch"
"Word64"
(\t -> case readMaybe t of
Nothing -> fail "Invalid Log Epoch"
Just x -> pure x
)
errorLogCommitHash <- o .: "commit-hash" errorLogCommitHash <- o .: "commit-hash"
errorLogSourceFile <- o .: "file" errorLogSourceFile <- o .: "file"
errorLogLine <- o .: "line" errorLogLine <- o .: "line"

View File

@@ -82,7 +82,7 @@ EosHash
ErrorLogRecord ErrorLogRecord
createdAt UTCTime createdAt UTCTime
epoch Word64 epoch Text
commitHash Text commitHash Text
sourceFile Text sourceFile Text
line Word32 line Word32