Skip to content

Commit

Permalink
chore: use total runs intead of uptime.Total()
Browse files Browse the repository at this point in the history
  • Loading branch information
adityathebe committed Jul 5, 2023
1 parent 86313fd commit c2ccedc
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
4 changes: 0 additions & 4 deletions pkg/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,6 @@ type Uptime struct {
LastFail *time.Time `json:"last_fail,omitempty"`
}

func (u Uptime) Total() int {
return u.Passed + u.Failed
}

func (u Uptime) String() string {
if u.Passed == 0 && u.Failed == 0 {
return ""
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func CheckDetails(c echo.Context) error {
}

checkSummary := *summary[0]
totalChecks := checkSummary.Uptime.Total()
totalChecks := checkSummary.TotalRuns
if totalChecks <= desiredNumOfCheckStatuses {
q.WindowDuration = 0 // No need to perform window aggregation
} else {
Expand Down
13 changes: 7 additions & 6 deletions pkg/api/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ func errorResonse(c echo.Context, err error, code int) error {
return c.JSON(code, e)
}

// returns the absolute value of i.
// math.Abs only supports float64 and this avoid hairy type conversions.
func abs(i int) int {
if i > 0 {
return i
// abs returns the absolute value of i.
// math.Abs only supports float64 and this avoids the needless type conversions
// and ugly expression.
func abs(n int) int {
if n > 0 {
return n
}

return -i
return -n
}

0 comments on commit c2ccedc

Please sign in to comment.