Skip to content
This repository has been archived by the owner on May 31, 2021. It is now read-only.

feat: 存在しないcontest_idでリクエストしたときただのnullが返ってたのをjsonの中に入れるようにした #33

Merged
merged 1 commit into from Aug 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/domain/Contest/database/contest_repository.py
Expand Up @@ -19,4 +19,6 @@ def find(self, contest_id: str) -> Contest:
row = self.sqlhandler.query(
"SELECT * FROM contests WHERE contest_id=%s", (contest_id,)
).fetch_one()
if len(row) == 0:
return None
return Contest(*row)
10 changes: 8 additions & 2 deletions src/interface/controllers/contest_controller.py
Expand Up @@ -16,5 +16,11 @@ async def contests(self, req, resp):

async def contest(self, req, resp, *, contest_id):
contest = self.interactor.contest(contest_id)
resp.media = {"contest": contest.as_json()}
resp.status_code = 200
if contest is None:
res_data = None
res_code = 400
else:
res_data = contest.as_json()
res_code = 200
resp.media = {"contest": res_data}
resp.status_code = res_code