-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
235 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from bracket.database import database | ||
from bracket.models.db.match import Match, MatchCreateBody | ||
|
||
|
||
async def sql_delete_match(match_id: int) -> None: | ||
query = ''' | ||
DELETE FROM matches | ||
WHERE matches.id = :match_id | ||
''' | ||
await database.execute(query=query, values={'match_id': match_id}) | ||
|
||
|
||
async def sql_create_match(match: MatchCreateBody) -> Match: | ||
async with database.transaction(): | ||
query = ''' | ||
INSERT INTO matches (round_id, team1_id, team2_id, team1_score, team2_score, label, created) | ||
VALUES (:round_id, :team1_id, :team2_id, 0, 0, :label, NOW()) | ||
RETURNING * | ||
''' | ||
result = await database.fetch_one(query=query, values=match.dict()) | ||
|
||
if result is None: | ||
raise ValueError('Could not create stage') | ||
|
||
return Match.parse_obj(result._mapping) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.