Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Issue History #1221

Merged
merged 5 commits into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions epictrack-api/src/api/models/work_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ class WorkIssues(BaseModelVersioned):
work_id = Column(ForeignKey('works.id'), nullable=False)
work = relationship('Work', foreign_keys=[work_id], lazy='select')

updates = relationship('WorkIssueUpdates', back_populates='work_issue', lazy='joined')
updates = relationship('WorkIssueUpdates', back_populates='work_issue', lazy='joined', order_by='desc(WorkIssueUpdates.id)')

@classmethod
def list_issues_for_work_id(cls, work_id) -> List[WorkIssues]:
"""List all WorkIssues sorted by start_date, with approved issues first."""
"""List all WorkIssues sorted by start_date."""
query = (
WorkIssues.query
.filter(cls.work_id == work_id)
.order_by(cls.is_approved.desc(), cls.start_date)
.order_by(cls.start_date.desc())
)
return query.all()
3 changes: 2 additions & 1 deletion epictrack-api/src/api/resources/work_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ def put(work_id, issue_id):
return res.WorkIssuesResponseSchema().dump(work_issues), HTTPStatus.CREATED


@API.route("/<int:issue_id>/update", methods=["POST"])
@cors_preflight("POST")
@API.route("/<int:issue_id>/issue_update", methods=["POST", "OPTIONS"])
class WorkIssueUpdate(Resource):
"""Endpoint resource to manage updates for a specific issue."""

Expand Down
3 changes: 0 additions & 3 deletions epictrack-api/src/api/services/work_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,12 @@ def add_work_issue_update(cls, work_id, issue_id, description_data: List[str]):
"""Add a new description to the existing Issue."""
work_issues = WorkIssuesModel.find_by_params({"work_id": work_id,
"id": issue_id})

if not work_issues:
raise ResourceNotFoundError("Work Issues not found")

for description in description_data:
new_update = WorkIssueUpdatesModel(description=description)
new_update.work_issue_id = work_issues[0].id
new_update.save()

return WorkIssuesModel.find_by_id(issue_id)

@classmethod
Expand Down
Loading