From a17cd385954ffc3d4ff436902fc1c702bf7abd91 Mon Sep 17 00:00:00 2001 From: Alexandre Dulaunoy Date: Sun, 22 Aug 2021 23:23:52 +0200 Subject: [PATCH] chg: [api] lookup add parent details --- bin/server.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/bin/server.py b/bin/server.py index afa177e..2239cb0 100644 --- a/bin/server.py +++ b/bin/server.py @@ -93,6 +93,12 @@ class lookup(Resource): if "ProductCode" in h: if rdb.exists("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 @api.route('/lookup/sha1/') @@ -132,6 +138,13 @@ class lookup(Resource): if "ProductCode" in h: if rdb.exists("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 @api.route('/info')