From 429cea9c0787876820984a2df4e982449a84c10e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Tue, 21 May 2019 12:30:28 +0200 Subject: [PATCH] fix: Exception when AS isn't known. --- bgpranking/querying.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bgpranking/querying.py b/bgpranking/querying.py index faa9dfc..6c4fd17 100644 --- a/bgpranking/querying.py +++ b/bgpranking/querying.py @@ -132,7 +132,10 @@ class Querying(): if not r: r = 0 if with_position and not source: - to_return['response'] = {'rank': float(r), 'position': self.cache.zrevrank(key, asn) + 1, + position = self.cache.zrevrank(key, asn) + if position is not None: + position += 1 + to_return['response'] = {'rank': float(r), 'position': position, 'total_known_asns': self.cache.zcard(key)} else: to_return['response'] = float(r)