From 4be3636a39091abbfe12ba04407670b899c024ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Tue, 10 Apr 2018 11:57:47 +0200 Subject: [PATCH] fix: Only add ranking if the rank isn't 0 --- bgpranking/ranking.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/bgpranking/ranking.py b/bgpranking/ranking.py index c8c5f00..d4c61a0 100644 --- a/bgpranking/ranking.py +++ b/bgpranking/ranking.py @@ -69,13 +69,15 @@ class Ranking(): v4count = self.asn_meta.get(f'{v4_last}|{asn}|v4|ipcount') v6count = self.asn_meta.get(f'{v6_last}|{asn}|v6|ipcount') if v4count: - asn_rank_v4 /= int(v4count) - r_pipeline.set(f'{today}|{source}|{asn}|rankv4', asn_rank_v4) - r_pipeline.zincrby(asns_aggregation_key_v4, asn, asn_rank_v4) + asn_rank_v4 /= float(v4count) + if asn_rank_v4: + r_pipeline.set(f'{today}|{source}|{asn}|rankv4', asn_rank_v4) + r_pipeline.zincrby(asns_aggregation_key_v4, asn, asn_rank_v4) if v6count: - asn_rank_v6 /= int(v6count) - r_pipeline.set(f'{today}|{source}|{asn}|rankv6', asn_rank_v6) - r_pipeline.zincrby(asns_aggregation_key_v6, asn, asn_rank_v6) + asn_rank_v6 /= float(v6count) + if asn_rank_v6: + r_pipeline.set(f'{today}|{source}|{asn}|rankv6', asn_rank_v6) + r_pipeline.zincrby(asns_aggregation_key_v6, asn, asn_rank_v6) r_pipeline.execute() unset_running(self.__class__.__name__)