Skip to content

Commit

Permalink
Update reputation bucket ranges
Browse files Browse the repository at this point in the history
  • Loading branch information
cryptobench committed Sep 18, 2024
1 parent e5f1fe8 commit 1e3cc90
Showing 1 changed file with 17 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,30 +83,29 @@ def cache_provider_uptime():
provider_ids = [status.provider_id for status in latest_statuses if status.is_online]


# Calculate uptime percentages
uptime_data = {
'100-80': 0,
'80-40': 0,
'40-0': 0
}

uptime_data = {
'100-99': 0,
'99-98': 0,
'100-90': 0,
'90-80': 0,
'80-60': 0,
'60-40': 0,
'40-20': 0,
'20-0': 0
}
uptime_data.update({f'{i}-{i-10}': 0 for i in range(90, 0, -10)})

for provider_id in provider_ids:
uptime_percentage = calculate_uptime(provider_id)
if uptime_percentage >= 99:
uptime_data['100-99'] += 1
elif uptime_percentage >= 98:
uptime_data['99-98'] += 1
if uptime_percentage >= 90:
uptime_data['100-90'] += 1
elif uptime_percentage >= 80:
uptime_data['90-80'] += 1
elif uptime_percentage >= 60:
uptime_data['80-60'] += 1
elif uptime_percentage >= 40:
uptime_data['60-40'] += 1
elif uptime_percentage >= 20:
uptime_data['40-20'] += 1
else:
for i in range(90, 0, -10):
if uptime_percentage >= i - 10:
uptime_data[f'{i}-{i-10}'] += 1
break
uptime_data['20-0'] += 1

redis_client.set('stats_provider_uptime', json.dumps(uptime_data))

Expand Down

0 comments on commit 1e3cc90

Please sign in to comment.