Skip to content

Commit

Permalink
Fix average client calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
sfan5 committed Feb 17, 2025
1 parent de30a4e commit 258add9
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion server.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,7 @@ def get_error_pk(self):

def get_average_clients(self):
if self.updateCount:
# FIXME: this is quite biased to servers that are new (or restart often)
return round(self.totalClients / self.updateCount)
return 0

Expand Down Expand Up @@ -582,7 +583,7 @@ def track_update(self, old: 'Server', is_update: bool):
# Popularity
if old:
self.updateCount = old.updateCount + 1
self.totalClients += self.meta["clients"]
self.totalClients = old.totalClients + self.meta["clients"]
self.meta["clients_top"] = max(self.meta["clients"], old.meta["clients_top"])
else:
self.updateCount = 1
Expand Down

0 comments on commit 258add9

Please sign in to comment.