Skip to content

Commit

Permalink
feat: Update field to use type
Browse files Browse the repository at this point in the history
  • Loading branch information
Pradip-p committed Aug 6, 2024
1 parent a412fbf commit 170753e
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 67 deletions.
4 changes: 1 addition & 3 deletions src/backend/app/db/db_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,7 @@ class DbProject(Base):
),
)
author = relationship(DbUser, uselist=False, backref="user")
final_output = cast(
FinalOutput, Column(Enum(FinalOutput), default=FinalOutput.ORTHOPHOTO_2D)
)
final_output = cast(FinalOutput, Column(ARRAY(String)))
auto_lock_tasks = cast(bool, Column(Boolean, default=False))
# PROJECT STATUS
status = cast(
Expand Down
57 changes: 0 additions & 57 deletions src/backend/app/migrations/versions/b574d3a13e62_.py

This file was deleted.

32 changes: 32 additions & 0 deletions src/backend/app/migrations/versions/c1ee756a3449_.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""
Revision ID: c1ee756a3449
Revises: 87b6f9d734e8
Create Date: 2024-08-06 11:06:12.267127
"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = 'c1ee756a3449'
down_revision: Union[str, None] = '87b6f9d734e8'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('projects', sa.Column('final_output', sa.ARRAY(sa.String()), nullable=True))
op.add_column('projects', sa.Column('auto_lock_tasks', sa.Boolean(), nullable=True))
# ### end Alembic commands ###


def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('projects', 'auto_lock_tasks')
op.drop_column('projects', 'final_output')
# ### end Alembic commands ###
10 changes: 5 additions & 5 deletions src/backend/app/models/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ class IntEnum(int, Enum):
pass


class FinalOutput(IntEnum, Enum):
ORTHOPHOTO_2D = 0
ORTHOPHOTO_3D = 1
DIGITAL_TERRAIN_MODEL = 2
DIGITAL_SURFACE_MODEL = 3
class FinalOutput(str, Enum):
ORTHOPHOTO_2D = "ORTHOPHOTO_2D"
ORTHOPHOTO_3D = "ORTHOPHOTO_3D"
DIGITAL_TERRAIN_MODEL = "DIGITAL_TERRAIN_MODEL"
DIGITAL_SURFACE_MODEL = "DIGITAL_SURFACE_MODEL"


class TaskStatus(IntEnum, Enum):
Expand Down
2 changes: 1 addition & 1 deletion src/backend/app/projects/project_crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ async def create_project_with_project_info(
"output_raw_url": project_metadata.output_raw_url,
"task_split_dimension": project_metadata.task_split_dimension,
"deadline_at": project_metadata.deadline_at,
"final_output": project_metadata.final_output.name,
"final_output": project_metadata.final_output,
"auto_lock_tasks": project_metadata.auto_lock_tasks,
},
)
Expand Down
10 changes: 9 additions & 1 deletion src/backend/app/projects/project_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,15 @@ class ProjectIn(BaseModel):
output_raw_url: Optional[str] = None
deadline_at: Optional[date] = None
visibility: Optional[ProjectVisibility] = ProjectVisibility.PUBLIC
final_output: Optional[FinalOutput] = FinalOutput.ORTHOPHOTO_2D
final_output: List[FinalOutput] = Field(
...,
example=[
"ORTHOPHOTO_2D",
"ORTHOPHOTO_3D",
"DIGITAL_TERRAIN_MODEL",
"DIGITAL_SURFACE_MODEL",
],
)
auto_lock_tasks: Optional[bool] = False

@computed_field
Expand Down

0 comments on commit 170753e

Please sign in to comment.