in azure-kusto-ingest/azure/kusto/ingest/_ranked_storage_account.py [0:0]
def get_rank(self) -> float:
rank = 0
total_weight = 0
# For each bucket, calculate the success rate ( success / total ) and multiply it by the bucket weight.
# The older the bucket, the less weight it has. For example, if there are 3 buckets, the oldest bucket will have
# a weight of 1, the middle bucket will have a weight of 2 and the newest bucket will have a weight of 3.
for i in range(1, self.number_of_buckets + 1):
bucket_index = (self.current_bucket_index + i) % self.number_of_buckets
bucket = self.buckets[bucket_index]
if bucket.total_count == 0:
continue
success_rate = bucket.success_count / bucket.total_count
rank += success_rate * i
total_weight += i
# If there are no buckets with data, return 1 (highest rank)
if total_weight == 0:
return 1
return rank / total_weight