Skip to content

Commit

Permalink
feat: use int64 for check status duration
Browse files Browse the repository at this point in the history
  • Loading branch information
adityathebe committed Sep 27, 2024
1 parent 1911d01 commit 51d24a3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 19 deletions.
3 changes: 1 addition & 2 deletions cmd/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ func init() {
Push.Flags().StringVar(&status.Error, "error", "", "Error of check")
Push.Flags().StringVar(&status.Message, "message", "", "Message of check")
Push.Flags().StringVar(&details, "detail", "", "Detail of check")
Push.Flags().IntVar(&status.Duration, "duration", 0, "Duration of check in milliseconds")
// Push.Flags().StringVar(&status.Time, "time", "", "Time of check")
Push.Flags().Int64Var(&status.DurationMs, "duration", 0, "Duration of check in milliseconds")
Push.Flags().BoolVar(&status.Status, "passed", true, "Passed status of check")
Root.AddCommand(Push)
}
32 changes: 16 additions & 16 deletions pkg/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ func (t *JSONTime) UnmarshalJSON(b []byte) error {
}

type CheckStatus struct {
Status bool `json:"status"`
Invalid bool `json:"invalid,omitempty"`
Time string `json:"time"`
Duration int `json:"duration"`
Message string `json:"message,omitempty"`
Error string `json:"error,omitempty"`
Detail interface{} `json:"-"`
Check *external.Check `json:"check,omitempty"`
Status bool `json:"status"`
Invalid bool `json:"invalid,omitempty"`
Time string `json:"time"`
DurationMs int64 `json:"duration"`
Message string `json:"message,omitempty"`
Error string `json:"error,omitempty"`
Detail interface{} `json:"-"`
Check *external.Check `json:"check,omitempty"`
}

func (s CheckStatus) GetTime() (time.Time, error) {
Expand Down Expand Up @@ -194,14 +194,14 @@ func FromExternalCheck(canary Canary, check external.Check) Check {

func CheckStatusFromResult(result CheckResult) CheckStatus {
return CheckStatus{
Status: result.Pass,
Invalid: result.Invalid,
Duration: int(result.Duration),
Time: time.Now().UTC().Format(time.RFC3339),
Message: result.Message,
Error: result.Error,
Detail: result.Detail,
Check: &result.Check,
Status: result.Pass,
Invalid: result.Invalid,
DurationMs: result.Duration,
Time: time.Now().UTC().Format(time.RFC3339),
Message: result.Message,
Error: result.Error,
Detail: result.Detail,
Check: &result.Check,
}
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/cache/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func (c *postgresCache) AddCheckStatus(conn *gorm.DB, check pkg.Check, status pk
`,
checks[0].ID,
string(jsonDetails),
status.Duration,
status.DurationMs,
status.Error,
status.Invalid,
status.Message,
Expand Down

0 comments on commit 51d24a3

Please sign in to comment.