Skip to content

Commit af1b566

Browse files
Update views.py
1 parent 8dc0a63 commit af1b566

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

frameworks/Python/aiohttp/app/views.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
randint = random.randint
2323
sample = random.sample
2424
Response = aiohttp.web.Response
25-
json_response = aiohttp.web.json_response
2625
select = sqlalchemy.select
2726
flag_modified = sqlalchemy.orm.attributes.flag_modified
2827
Fortune = models.Fortune
@@ -51,6 +50,14 @@ def get_num_queries(request):
5150
return 500
5251
return num_queries
5352

53+
54+
def json_response(payload):
55+
return Response(
56+
body=orjson.dumps(payload),
57+
content_type="application/json",
58+
)
59+
60+
5461
async def json(request):
5562
"""
5663
Test 1
@@ -170,9 +177,9 @@ async def updates_raw(request):
170177

171178
async with request.app['pg'].acquire() as conn:
172179
stmt = await conn.prepare(READ_ROW_SQL)
173-
for row_id in ids:
180+
for id_, _ in updates:
174181
# the result of this is the int previous random number which we don't actually use
175-
await stmt.fetchval(row_id)
182+
await stmt.fetchval(id_)
176183
await conn.executemany(WRITE_ROW_SQL, updates)
177184

178185
return json_response(worlds)

0 commit comments

Comments
 (0)