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

Commit

Permalink
Merge pull request #33 from SoyBeansLab/feature/contest-domain
Browse files Browse the repository at this point in the history
feat: 存在しないcontest_idでリクエストしたときただのnullが返ってたのをjsonの中に入れるようにした
  • Loading branch information
ucpr committed Aug 19, 2019
2 parents a75fcb5 + 1aae922 commit 998b369
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
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

0 comments on commit 998b369

Please sign in to comment.