Skip to content

Commit

Permalink
Add Issue History (#1221)
Browse files Browse the repository at this point in the history
* #1119: #1047:

* Add Issue History component

* remove mock

* debug

* remove debug line
  • Loading branch information
jadmsaadaot authored Nov 13, 2023
1 parent d775aab commit e3f925a
Show file tree
Hide file tree
Showing 17 changed files with 5,992 additions and 11,237 deletions.
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

0 comments on commit e3f925a

Please sign in to comment.