mirror of
https://github.com/adulau/hashlookup-server.git
synced 2024-11-27 12:37:13 +00:00
fix: [api:md5/sha1] large set of parents are now limited and give a random selection
TODO: mainly empty files and similar - warning-lists should be added
This commit is contained in:
parent
74c0e8c8c2
commit
c470201fd8
1 changed files with 13 additions and 2 deletions
|
@ -114,7 +114,12 @@ class lookup(Resource):
|
|||
h['ProductCode'] = rdb.hgetall("h-ProductCode:{}".format(h['ProductCode']))
|
||||
if rdb.exists("p:{}".format(sha1)):
|
||||
parents = []
|
||||
for parent in rdb.smembers("p:{}".format(sha1)):
|
||||
card = rdb.scard("p:{}".format(sha1))
|
||||
if card <= 15:
|
||||
p = rdb.smembers("p:{}".format(sha1))
|
||||
else:
|
||||
p = rdb.srandmember("p:{}".format(sha1), number=10)
|
||||
for parent in p:
|
||||
parent_details = rdb.hgetall("h:{}".format(parent))
|
||||
parents.append(parent_details)
|
||||
h['parents'] = parents
|
||||
|
@ -162,7 +167,13 @@ class lookup(Resource):
|
|||
h['ProductCode'] = rdb.hgetall("h-ProductCode:{}".format(h['ProductCode']))
|
||||
if rdb.exists("p:{}".format(k)):
|
||||
parents = []
|
||||
for parent in rdb.smembers("p:{}".format(k)):
|
||||
card = rdb.scard("p:{}".format(k))
|
||||
if card <= 15:
|
||||
p = rdb.smembers("p:{}".format(k))
|
||||
else:
|
||||
p = []
|
||||
p = rdb.srandmember("p:{}".format(sha1), number=10)
|
||||
for parent in p:
|
||||
parent_details = rdb.hgetall("h:{}".format(parent))
|
||||
parents.append(parent_details)
|
||||
h['parents'] = parents
|
||||
|
|
Loading…
Reference in a new issue