chg: [api] lookup add parent details

This commit is contained in:
Alexandre Dulaunoy 2021-08-22 23:23:52 +02:00
parent 8504b492f7
commit a17cd38595
Signed by: adulau
GPG key ID: 09E2CD4944E6CBCD

View file

@ -93,6 +93,12 @@ class lookup(Resource):
if "ProductCode" in h: if "ProductCode" in h:
if rdb.exists("h-ProductCode:{}".format(h['ProductCode'])): if rdb.exists("h-ProductCode:{}".format(h['ProductCode'])):
h['ProductCode'] = rdb.hgetall("h-ProductCode:{}".format(h['ProductCode'])) h['ProductCode'] = rdb.hgetall("h-ProductCode:{}".format(h['ProductCode']))
if rdb.exists("p:{}".format(sha1)):
parents = []
for parent in rdb.smembers("p:{}".format(sha1)):
parent_details = rdb.hgetall("h:{}".format(parent))
parents.append(parent_details)
h['parents'] = parents
return h return h
@api.route('/lookup/sha1/<string:sha1>') @api.route('/lookup/sha1/<string:sha1>')
@ -132,6 +138,13 @@ class lookup(Resource):
if "ProductCode" in h: if "ProductCode" in h:
if rdb.exists("h-ProductCode:{}".format(h['ProductCode'])): if rdb.exists("h-ProductCode:{}".format(h['ProductCode'])):
h['ProductCode'] = rdb.hgetall("h-ProductCode:{}".format(h['ProductCode'])) h['ProductCode'] = rdb.hgetall("h-ProductCode:{}".format(h['ProductCode']))
if rdb.exists("p:{}".format(k)):
parents = []
for parent in rdb.smembers("p:{}".format(sha1)):
parent_details = rdb.hgetall("h:{}".format(parent))
parents.append(parent_details)
h['parents'] = parents
return h return h
@api.route('/info') @api.route('/info')