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 a29f31c commit e9e9477
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions stats-backend/api2/scoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ 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()
online_duration = timedelta(0)
last_online_time = None

Expand All @@ -22,7 +22,7 @@ def calculate_uptime_percentage(node_id, node=None):
if last_online_time is not None:
online_duration += timezone.now() - last_online_time

total_duration = timezone.now() - node.uptime_created_at
total_duration = timezone.now() - first_online_status.timestamp
uptime_percentage = (
online_duration.total_seconds() / total_duration.total_seconds()
) * 100
Expand Down

0 comments on commit e9e9477

Please sign in to comment.