From a78a99ec4405f22944fcec914986cd2ccc13c961 Mon Sep 17 00:00:00 2001 From: Alexandre Dulaunoy Date: Sun, 31 Oct 2021 09:04:25 +0100 Subject: [PATCH] new: [api] add a `hashlookup:parent-total` which indicates the cardinality of the parents This can be used for the new API endpoint to paginate over large set of parents. --- bin/server.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bin/server.py b/bin/server.py index c41d925..39a7d28 100644 --- a/bin/server.py +++ b/bin/server.py @@ -48,7 +48,7 @@ def client_info(): else: ip = request.environ['HTTP_X_FORWARDED_FOR'] user_agent = request.headers.get('User-Agent') - if request.environ.get('HTTP_AUTHENTICATION') is not None: + if request.environ.get('HTTP_AUTHORIZATION') is not None: auth = request.environ.get('HTTP_AUTHORIZATION') else: auth = None @@ -123,6 +123,7 @@ class lookup(Resource): p = rdb.smembers("p:{}".format(sha1)) else: p = rdb.srandmember("p:{}".format(sha1), number=10) + h['hashlookup:parent-total'] = card for parent in p: parent_details = rdb.hgetall("h:{}".format(parent)) parents.append(parent_details) @@ -177,6 +178,7 @@ class lookup(Resource): else: p = [] p = rdb.srandmember("p:{}".format(k), number=10) + h['hashlookup:parent-total'] = card for parent in p: parent_details = rdb.hgetall("h:{}".format(parent)) parents.append(parent_details)