Skip to content
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

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from

Conversation

jemand771
Copy link
Member

This is a copy of statping#1080
The commits still have their original author, so imo this isn't "stealing" or anything.

cc @dipeshhkc

@jemand771
Copy link
Member Author

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

@adamboutcher adamboutcher added the Bug Something isn't working label Aug 4, 2022
@adamboutcher
Copy link
Collaborator

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
Copy link
Collaborator

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.

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
Copy link
Collaborator

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?

@adamboutcher
Copy link
Collaborator

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

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.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants