From df314c067755260888a07beb65f1f44ae047a554 Mon Sep 17 00:00:00 2001 From: Marian Steinbach Date: Thu, 11 Nov 2021 20:09:20 +0100 Subject: [PATCH] Fix bug --- rating/network_payload.py | 11 ++++++----- rating/network_requests.py | 11 ++++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/rating/network_payload.py b/rating/network_payload.py index 3af0c46..0fb6e65 100644 --- a/rating/network_payload.py +++ b/rating/network_payload.py @@ -42,11 +42,12 @@ class Rater(AbstractRater): # Calculate score based on the largest value found for a URL. # See https://github.com/netzbegruenung/green-spider/issues/11#issuecomment-600307544 # for details. - value = max(payloads_for_urls) - if value < 994000: - score = 1 - elif value < 1496000: - score = .5 + if len(payloads_for_urls) > 0: + value = max(payloads_for_urls) + if value < 994000: + score = 1 + elif value < 1496000: + score = .5 return { 'type': self.rating_type, diff --git a/rating/network_requests.py b/rating/network_requests.py index a2e4344..b3a0229 100644 --- a/rating/network_requests.py +++ b/rating/network_requests.py @@ -42,11 +42,12 @@ class Rater(AbstractRater): # Calculate score based on the largest value found for a URL. # See https://github.com/netzbegruenung/green-spider/issues/11#issuecomment-600307544 # for details. - value = max(num_requests_for_urls) - if value <= 28: - score = 1.0 - elif value <= 38: - score = 0.5 + if len(num_requests_for_urls) > 0: + value = max(num_requests_for_urls) + if value <= 28: + score = 1.0 + elif value <= 38: + score = 0.5 return { 'type': self.rating_type,