Skip to content

Commit 17ae76a

Browse files
committed
response schema changes
1 parent f27e8e3 commit 17ae76a

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

app.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,20 @@ def get_data():
5959
def group_by_owner(data):
6060
grouped_data = defaultdict(list)
6161
for record in data:
62-
owner = record['owner']
63-
grouped_data[owner].append(record)
64-
return grouped_data
62+
owner = record['owner']
63+
grouped_data[owner].append(record)
64+
65+
66+
#Arrange data as reponse format
67+
res = []
68+
for val in grouped_data:
69+
dict_ = {}
70+
dict_['org_name'] = val
71+
dict_['issues'] = grouped_data[val]
72+
73+
res.append(dict_)
74+
75+
return {"issues":res}
6576

6677
@app.route('/api/issues', methods=['GET'])
6778
def get_issues():
@@ -124,6 +135,7 @@ def get_issues_by_owner(owner):
124135
if not response.data:
125136
return jsonify({'error': "No data found"}), 500
126137
data = response.data
138+
data = [{**item, "name": item["owner"]} for item in data]
127139
return jsonify(data)
128140
except Exception as e:
129141
return jsonify({'error': str(e)}), 500

0 commit comments

Comments
 (0)