forked from acm-ndsu/byte_le_engine
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #116 from JeanAEckelberg/restructure-database
Restructure database
- Loading branch information
Showing
61 changed files
with
410 additions
and
291 deletions.
There are no files selected for viewing
Binary file not shown.
This file was deleted.
Oops, something went wrong.
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,54 @@ | ||
from sqlalchemy.orm import Session | ||
|
||
from server.models.group_teams import GroupTeams | ||
from server.schemas.group_teams.group_teams_schema import GroupTeamsBase | ||
|
||
|
||
def create(db: Session, group_teams: GroupTeamsBase) -> GroupTeams: | ||
db_group_teams: GroupTeams = GroupTeams(**group_teams.model_dump(exclude={'group_teams_id'})) | ||
db.add(db_group_teams) | ||
db.commit() | ||
db.refresh(db_group_teams) | ||
return db_group_teams | ||
|
||
|
||
def read(db: Session, id: int) -> GroupTeams | None: | ||
return (db.query(GroupTeams) | ||
.filter(GroupTeams.group_teams_id == id) | ||
.first()) | ||
|
||
|
||
def read_all(db: Session) -> [GroupTeams]: | ||
return db.query(GroupTeams).all() | ||
|
||
|
||
def read_all_W_filter(db: Session, **kwargs) -> [GroupTeams]: | ||
return (db.query(GroupTeams) | ||
.filter_by(**kwargs) | ||
.all()) | ||
|
||
|
||
def update(db: Session, id: int, group_teams: GroupTeamsBase) -> GroupTeams | None: | ||
db_group_teams: GroupTeams | None = (db.query(GroupTeams) | ||
.filter(GroupTeams.group_teams_id == id) | ||
.one_or_none()) | ||
if db_group_teams is None: | ||
return | ||
|
||
for key, value in group_teams.model_dump().items(): | ||
setattr(db_group_teams, key, value) if value is not None else None | ||
|
||
db.commit() | ||
db.refresh(db_group_teams) | ||
return db_group_teams | ||
|
||
|
||
def delete(db: Session, id: int, group_teams: GroupTeamsBase) -> None: | ||
db_group_teams: GroupTeams | None = (db.query(GroupTeams) | ||
.filter(GroupTeams.group_teams_id == id) | ||
.one_or_none()) | ||
if db_group_teams is None: | ||
return | ||
|
||
db.delete(db_group_teams) | ||
db.commit() |
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,55 @@ | ||
from sqlalchemy.orm import Session | ||
|
||
from server.models.submission_run_info import SubmissionRunInfo | ||
from server.schemas.submission_run_info.submission_run_info_schema import SubmissionRunInfoBase | ||
|
||
|
||
def create(db: Session, submission_run_info: SubmissionRunInfoBase) -> SubmissionRunInfo: | ||
db_submission_run_info: SubmissionRunInfo = SubmissionRunInfo(**submission_run_info.model_dump( | ||
exclude={'submission_run_info_id'})) | ||
db.add(db_submission_run_info) | ||
db.commit() | ||
db.refresh(db_submission_run_info) | ||
return db_submission_run_info | ||
|
||
|
||
def read(db: Session, id: int) -> SubmissionRunInfo | None: | ||
return (db.query(SubmissionRunInfo) | ||
.filter(SubmissionRunInfo.submission_run_info_id == id) | ||
.first()) | ||
|
||
|
||
def read_all(db: Session) -> [SubmissionRunInfo]: | ||
return db.query(SubmissionRunInfo).all() | ||
|
||
|
||
def read_all_W_filter(db: Session, **kwargs) -> [SubmissionRunInfo]: | ||
return (db.query(SubmissionRunInfo) | ||
.filter_by(**kwargs) | ||
.all()) | ||
|
||
|
||
def update(db: Session, id: int, submission_run_info: SubmissionRunInfoBase) -> SubmissionRunInfo | None: | ||
db_submission_run_info: SubmissionRunInfo | None = (db.query(SubmissionRunInfo) | ||
.filter(SubmissionRunInfo.submission_run_info_id == id) | ||
.one_or_none()) | ||
if db_submission_run_info is None: | ||
return | ||
|
||
for key, value in submission_run_info.model_dump().items(): | ||
setattr(db_submission_run_info, key, value) if value is not None else None | ||
|
||
db.commit() | ||
db.refresh(db_submission_run_info) | ||
return db_submission_run_info | ||
|
||
|
||
def delete(db: Session, id: int, submission_run_info: SubmissionRunInfoBase) -> None: | ||
db_submission_run_info: SubmissionRunInfo | None = (db.query(SubmissionRunInfo) | ||
.filter(SubmissionRunInfo.submission_run_info_id == id) | ||
.one_or_none()) | ||
if db_submission_run_info is None: | ||
return | ||
|
||
db.delete(db_submission_run_info) | ||
db.commit() |
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,54 @@ | ||
from sqlalchemy.orm import Session | ||
|
||
from server.models.team import Team | ||
from server.schemas.team.team_schema import TeamBase | ||
|
||
|
||
def create(db: Session, team: TeamBase) -> Team: | ||
db_team: Team = Team(**team.model_dump(exclude={'team_id'})) | ||
db.add(db_team) | ||
db.commit() | ||
db.refresh(db_team) | ||
return db_team | ||
|
||
|
||
def read(db: Session, id: int) -> Team | None: | ||
return (db.query(Team) | ||
.filter(Team.team_uuid == id) | ||
.first()) | ||
|
||
|
||
def read_all(db: Session) -> [Team]: | ||
return db.query(Team).all() | ||
|
||
|
||
def read_all_W_filter(db: Session, **kwargs) -> [Team]: | ||
return (db.query(Team) | ||
.filter_by(**kwargs) | ||
.all()) | ||
|
||
|
||
def update(db: Session, id: int, team: TeamBase) -> Team | None: | ||
db_team: Team | None = (db.query(Team) | ||
.filter(Team.team_uuid == id) | ||
.one_or_none()) | ||
if db_team is None: | ||
return | ||
|
||
for key, value in team.model_dump().items(): | ||
setattr(db_team, key, value) if value is not None else None | ||
|
||
db.commit() | ||
db.refresh(db_team) | ||
return db_team | ||
|
||
|
||
def delete(db: Session, id: int, team: TeamBase) -> None: | ||
db_team: Team | None = (db.query(Team) | ||
.filter(Team.team_uuid == id) | ||
.one_or_none()) | ||
if db_team is None: | ||
return | ||
|
||
db.delete(db_team) | ||
db.commit() |
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 was deleted.
Oops, something went wrong.
Oops, something went wrong.