Skip to content

Commit

Permalink
Update scoring.py
Browse files Browse the repository at this point in the history
  • Loading branch information
cryptobench committed Oct 4, 2024
1 parent e9e9477 commit e6b5003
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions stats-backend/api2/scoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@
def calculate_uptime_percentage(node_id, node=None):
if node is None:
node = Node.objects.get(node_id=node_id)
statuses = NodeStatusHistory.objects.filter(node_id=node_id).order_by("timestamp")
first_online_status = statuses.filter(is_online=True).first()
statuses = NodeStatusHistory.objects.filter(node_id=node_id, is_online=True).order_by("timestamp")
first_online_status = statuses.first()

if not first_online_status:
return 0 # Return 0% if the node has never been online
online_duration = timedelta(0)
last_online_time = None

Expand Down

0 comments on commit e6b5003

Please sign in to comment.