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.
This commit is contained in:
Alexandre Dulaunoy 2021-10-31 09:04:25 +01:00
parent 9e79d8ecc7
commit a78a99ec44
Signed by: adulau
GPG key ID: 09E2CD4944E6CBCD

View file

@ -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)