Skip to content

Commit

Permalink
fix: slove merge conflict with task_routes
Browse files Browse the repository at this point in the history
  • Loading branch information
Pradip-p committed Aug 6, 2024
2 parents 5a68f4c + ba72e24 commit 37a7996
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 19 deletions.
4 changes: 3 additions & 1 deletion src/backend/app/db/db_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,9 @@ 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(Enum(FinalOutput), default=FinalOutput.ORTHOPHOTO_2D)
)
auto_lock_tasks = cast(bool, Column(Boolean, default=False))
# PROJECT STATUS
status = cast(
Expand Down
38 changes: 26 additions & 12 deletions src/backend/app/migrations/versions/b574d3a13e62_.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,53 @@
Create Date: 2024-08-05 15:02:26.464109
"""

from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


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

final_output_enum = sa.Enum(
'ORTHOPHOTO_2D',
'ORTHOPHOTO_3D',
'DIGITAL_TERRAIN_MODEL',
'DIGITAL_SURFACE_MODEL',
name='finaloutput'
"ORTHOPHOTO_2D",
"ORTHOPHOTO_3D",
"DIGITAL_TERRAIN_MODEL",
"DIGITAL_SURFACE_MODEL",
name="finaloutput",
)


def upgrade() -> None:
final_output_enum.create(op.get_bind())

# ### commands auto generated by Alembic - please adjust! ###
op.add_column('projects', sa.Column('final_output', sa.Enum('ORTHOPHOTO_2D', 'ORTHOPHOTO_3D', 'DIGITAL_TERRAIN_MODEL', 'DIGITAL_SURFACE_MODEL', name='finaloutput'), nullable=True))
op.add_column('projects', sa.Column('auto_lock_tasks', sa.Boolean(), nullable=True))
op.add_column(
"projects",
sa.Column(
"final_output",
sa.Enum(
"ORTHOPHOTO_2D",
"ORTHOPHOTO_3D",
"DIGITAL_TERRAIN_MODEL",
"DIGITAL_SURFACE_MODEL",
name="finaloutput",
),
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')
op.drop_column("projects", "auto_lock_tasks")
op.drop_column("projects", "final_output")
# ### end Alembic commands ###
final_output_enum.drop(op.get_bind())
3 changes: 2 additions & 1 deletion src/backend/app/models/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ class IntEnum(int, Enum):

pass


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


class TaskStatus(IntEnum, Enum):
"""Enum describing available Task Statuses."""
Expand Down
4 changes: 2 additions & 2 deletions src/backend/app/projects/project_crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,15 @@ async def create_project_with_project_info(
"task_split_dimension": project_metadata.task_split_dimension,
"deadline_at": project_metadata.deadline_at,
"final_output": project_metadata.final_output.name,
"auto_lock_tasks":project_metadata.auto_lock_tasks,
"auto_lock_tasks": project_metadata.auto_lock_tasks,
},
)
return project_id

except Exception as e:
log.exception(e)
raise HTTPException(e) from e


async def get_project_by_id(db: Database, project_id: uuid.UUID):
"Get a single database project object by project_id"
Expand Down
1 change: 1 addition & 0 deletions src/backend/app/projects/project_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ async def delete_project_by_id(

return {"message": f"Project ID: {project_id} is deleted successfully."}


@router.post("/create_project", tags=["Projects"])
async def create_project(
project_info: project_schemas.ProjectIn,
Expand Down
1 change: 0 additions & 1 deletion src/backend/app/projects/project_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ class ProjectIn(BaseModel):
final_output: Optional[FinalOutput] = FinalOutput.ORTHOPHOTO_2D
auto_lock_tasks: Optional[bool] = False


@computed_field
@property
def no_fly_zones(self) -> Optional[Any]:
Expand Down
8 changes: 6 additions & 2 deletions src/backend/app/tasks/task_crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,11 @@ async def update_or_create_task_state(

result = await db.fetch_one(query, values)

return {"project_id": result["project_id"], "task_id": result["task_id"], "comment": comment}
return {
"project_id": result["project_id"],
"task_id": result["task_id"],
"comment": comment,
}


async def get_requested_user_id(
Expand Down Expand Up @@ -218,7 +222,7 @@ async def get_project_task_by_id(db: Database, user_id: str):
SELECT id FROM projects WHERE author_id = :user_id
"""
project_ids_result = await db.fetch_all(query=_sql, values={"user_id": user_id})
project_ids = [row['id'] for row in project_ids_result]
project_ids = [row["id"] for row in project_ids_result]
raw_sql = """
SELECT t.id AS task_id, te.event_id, te.user_id, te.project_id, te.comment, te.state, te.created_at
FROM tasks t
Expand Down

0 comments on commit 37a7996

Please sign in to comment.