mirror of
https://github.com/adulau/hashlookup-server.git
synced 2024-11-22 01:57:08 +00:00
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:
parent
9e79d8ecc7
commit
a78a99ec44
1 changed files with 3 additions and 1 deletions
|
@ -48,7 +48,7 @@ def client_info():
|
||||||
else:
|
else:
|
||||||
ip = request.environ['HTTP_X_FORWARDED_FOR']
|
ip = request.environ['HTTP_X_FORWARDED_FOR']
|
||||||
user_agent = request.headers.get('User-Agent')
|
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')
|
auth = request.environ.get('HTTP_AUTHORIZATION')
|
||||||
else:
|
else:
|
||||||
auth = None
|
auth = None
|
||||||
|
@ -123,6 +123,7 @@ class lookup(Resource):
|
||||||
p = rdb.smembers("p:{}".format(sha1))
|
p = rdb.smembers("p:{}".format(sha1))
|
||||||
else:
|
else:
|
||||||
p = rdb.srandmember("p:{}".format(sha1), number=10)
|
p = rdb.srandmember("p:{}".format(sha1), number=10)
|
||||||
|
h['hashlookup:parent-total'] = card
|
||||||
for parent in p:
|
for parent in p:
|
||||||
parent_details = rdb.hgetall("h:{}".format(parent))
|
parent_details = rdb.hgetall("h:{}".format(parent))
|
||||||
parents.append(parent_details)
|
parents.append(parent_details)
|
||||||
|
@ -177,6 +178,7 @@ class lookup(Resource):
|
||||||
else:
|
else:
|
||||||
p = []
|
p = []
|
||||||
p = rdb.srandmember("p:{}".format(k), number=10)
|
p = rdb.srandmember("p:{}".format(k), number=10)
|
||||||
|
h['hashlookup:parent-total'] = card
|
||||||
for parent in p:
|
for parent in p:
|
||||||
parent_details = rdb.hgetall("h:{}".format(parent))
|
parent_details = rdb.hgetall("h:{}".format(parent))
|
||||||
parents.append(parent_details)
|
parents.append(parent_details)
|
||||||
|
|
Loading…
Reference in a new issue