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.
* 3 New Files Made GroupRun, TeamType, and University model files * Added nullables Added nullables to existing files * Added unique Added the unique constraint to team_type_name and uni_name. * New things Added some new files and foreign keys. * Added new files Added errors and turn table files. * Fixes Added fixes to all the files as needed. * fixed? * fixed again * Small fix Added Integer() to the primary key of the run file. * Fixed Fixed more Integer() that was missing. --------- Co-authored-by: JuliaCaesar <[email protected]> Co-authored-by: JuliaCaesar <[email protected]>
- Loading branch information
1 parent
4a09d04
commit a8fe6ee
Showing
8 changed files
with
109 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from sqlalchemy import ForeignKey, Integer, String | ||
from sqlalchemy.orm import Mapped, mapped_column | ||
|
||
from server.models.base import Base | ||
|
||
|
||
class Errors(Base): | ||
__tablename__: str = 'errors' | ||
error_id: Mapped[int] = mapped_column(Integer(), primary_key=True, autoincrement=True) # run id pk | ||
run_id: Mapped[int] = mapped_column(Integer(), ForeignKey("run.run_id")) # run id | ||
submission_id: Mapped[int] = mapped_column(Integer(), ForeignKey("submission.submission_id")) # submission id fk | ||
error_txt: Mapped[str] = mapped_column(String(), nullable=True) |
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,18 @@ | ||
from __future__ import annotations | ||
|
||
from sqlalchemy import Boolean, Integer, String, DateTime | ||
from sqlalchemy.orm import relationship, Mapped, mapped_column | ||
|
||
from server.models.base import Base | ||
from server.models.run import Run | ||
|
||
|
||
class GroupRun(Base): | ||
# Date times are stored in UTC in ISO format | ||
__tablename__: str = 'group_run' | ||
group_run_id: Mapped[int] = mapped_column(Integer(), primary_key=True, autoincrement=True) | ||
start_run: Mapped[str] = mapped_column(DateTime(), nullable=False) | ||
launcher_version: Mapped[str] = mapped_column(String(10), nullable=False) | ||
runs_per_client: Mapped[int] = mapped_column(Integer(), nullable=False) | ||
is_finished: Mapped[bool] = mapped_column(Boolean(), default=False, nullable=False) | ||
runs: Mapped[list[Run]] = relationship() |
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,18 @@ | ||
from sqlalchemy import LargeBinary, Boolean, ForeignKey, Integer, DateTime | ||
from sqlalchemy.orm import Mapped, mapped_column | ||
|
||
from server.models.base import Base | ||
|
||
|
||
class Run(Base): | ||
__tablename__: str = 'run' | ||
run_id: Mapped[int] = mapped_column(Integer(), primary_key=True, autoincrement=True) | ||
group_run_id: Mapped[int] = mapped_column(Integer(), ForeignKey("group_run.group_run_id")) | ||
run_time: Mapped[str] = mapped_column(DateTime(), nullable=False) | ||
winner: Mapped[bool] = mapped_column(Boolean(), nullable=False) | ||
player_1: Mapped[int] = mapped_column(Integer(), nullable=False) | ||
player_2: Mapped[int] = mapped_column(Integer(), nullable=False) | ||
seed: Mapped[int] = mapped_column(Integer(), nullable=False) | ||
|
||
# results is a JSON file that's read in, so it needs to be a LargeBinary object. | ||
results: Mapped[str] = mapped_column(LargeBinary(), nullable=False) |
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,12 @@ | ||
from sqlalchemy import LargeBinary, ForeignKey, Integer, DateTime | ||
from sqlalchemy.orm import Mapped, mapped_column | ||
|
||
from server.models.base import Base | ||
|
||
|
||
class Submission(Base): | ||
__tablename__: str = 'submission' | ||
submission_id: Mapped[int] = mapped_column(Integer(), primary_key=True, autoincrement=True) | ||
team_id_uuid: Mapped[int] = mapped_column(Integer(), ForeignKey("team.team_id_uuid")) | ||
submission_time: Mapped[str] = mapped_column(DateTime(), nullable=False) | ||
file_txt: Mapped[str] = mapped_column(LargeBinary(), nullable=False) |
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,13 @@ | ||
from sqlalchemy import CheckConstraint, ForeignKey, Integer, String | ||
from sqlalchemy.orm import Mapped, mapped_column | ||
|
||
from server.models.base import Base | ||
from uuid import uuid4 | ||
|
||
|
||
class Team(Base): | ||
__tablename__: str = 'team' | ||
team_id_uuid: Mapped[int] = mapped_column(Integer(), primary_key=True, default=uuid4()) | ||
uni_id: Mapped[int] = mapped_column(Integer(), ForeignKey("university.uni_id")) | ||
team_type_id: Mapped[int] = mapped_column(Integer(), ForeignKey("team_type.team_type_id")) | ||
team_name: Mapped[str] = mapped_column(String(), CheckConstraint("team_name != ''"), unique=True, nullable=False) |
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,12 @@ | ||
from sqlalchemy import Integer, Boolean, CheckConstraint, String | ||
from sqlalchemy.orm import Mapped, mapped_column | ||
|
||
from server.models.base import Base | ||
|
||
|
||
class TeamType(Base): | ||
__tablename__: str = 'team_type' | ||
team_type_id: Mapped[int] = mapped_column(Integer(), primary_key=True, autoincrement=True) | ||
team_type_name: Mapped[str] = mapped_column(String(15), CheckConstraint("team_type_name != ''"), nullable=False, | ||
unique=True) | ||
eligible: bool = mapped_column(Boolean(), nullable=False) |
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,14 @@ | ||
from sqlalchemy import LargeBinary, ForeignKey, Integer | ||
from sqlalchemy.orm import Mapped, mapped_column | ||
|
||
from server.models.base import Base | ||
|
||
|
||
class TurnTable(Base): | ||
__tablename__: str = 'turn_table' | ||
turn_id: Mapped[int] = mapped_column(Integer(), primary_key=True) | ||
turn_number: Mapped[int] = mapped_column(Integer()) | ||
run_id: Mapped[int] = mapped_column(Integer(), ForeignKey('run.run_id')) | ||
turn_data: Mapped[str] = mapped_column(LargeBinary(), nullable=False) | ||
|
||
|
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,10 @@ | ||
from sqlalchemy import Integer, CheckConstraint, String | ||
from sqlalchemy.orm import Mapped, mapped_column | ||
|
||
from server.models.base import Base | ||
|
||
|
||
class University(Base): | ||
__tablename__: str = 'university' | ||
uni_id: Mapped[int] = mapped_column(Integer(), primary_key=True, autoincrement=True) | ||
uni_name: Mapped[str] = mapped_column(String(100), CheckConstraint("uni_name != ''"), nullable=False, unique=True) |