-
Notifications
You must be signed in to change notification settings - Fork 134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Import: fix uptime percentage #161
base: dev
Are you sure you want to change the base?
Conversation
fix: OnlineSince Calculation
To be clear, I haven't really tested the change (it seems to make sense, though) yet, just brought over the commits to my fork |
To be honest I've never seen an issue here... |
@@ -276,6 +276,7 @@ func (s Service) OnlineDaysPercent(days int) float32 { | |||
func (s *Service) OnlineSince(ago time.Time) float32 { | |||
failsList := s.FailuresSince(ago).Count() | |||
hitsList := s.HitsSince(ago).Count() | |||
totalList := failsList+hitsList |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do hits include fails, if so then this doesn't work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hits should only be successful responses
@@ -287,12 +288,8 @@ func (s *Service) OnlineSince(ago time.Time) float32 { | |||
return s.Online24Hours | |||
} | |||
|
|||
avg := (float64(failsList) / float64(hitsList)) * 100 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which is why this calc is done?
I suspect that the fix is correct though. The code base is generally not very good and very muddled. |
avg = 0 | ||
} | ||
amount, _ := strconv.ParseFloat(fmt.Sprintf("%0.2f", avg), 10) | ||
amount := (hitsList / totalList) * 100 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't work, as it's performing an integer division where totalList is always going to be >= to hitsLists, so it will always be 0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
amount := (float64(hitsList) / float64(totalList)) * 100
This is a copy of statping#1080
The commits still have their original author, so imo this isn't "stealing" or anything.
cc @dipeshhkc