Skip to content

Commit

Permalink
255: Visual high priority notes for UI. Quality changes for debugging… (
Browse files Browse the repository at this point in the history
#2428)

…. Only deals with UI and not PDF generation - that is to come.
  • Loading branch information
marklise authored Nov 11, 2024
1 parent 01c8d29 commit 302f4b2
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 6 deletions.
2 changes: 1 addition & 1 deletion epictrack-api/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ notes=FIXME,XXX,TODO
ignored-modules=flask_sqlalchemy,sqlalchemy,SQLAlchemy,alembic,scoped_session
ignored-classes=scoped_session
min-similarity-lines=15
disable=C0301,W0511, R0917, C0411, R1710, E1101, W4904
disable=C0301,W0511, R0917, C0411, R1710, E1101, W4904, R0914
good-names=f,id,k,v

[isort]
Expand Down
34 changes: 33 additions & 1 deletion epictrack-api/src/api/reports/anticipated_schedule_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
from api.models.event import Event
from api.models.event_category import EventCategoryEnum
from api.models.event_configuration import EventConfiguration
from api.models.work_issues import WorkIssues
from api.models.work_issue_updates import WorkIssueUpdates
from api.models.event_type import EventTypeEnum
from api.models.ministry import Ministry
from api.models.phase_code import PhaseCode
Expand Down Expand Up @@ -40,6 +42,8 @@ def __init__(self, filters, color_intensity):
"""Initialize the ReportFactory"""
data_keys = [
"work_id",
"event_id",
"work_issues",
"phase_name",
"date_updated",
"project_name",
Expand Down Expand Up @@ -191,6 +195,7 @@ def _fetch_data(self, report_date):
~WorkPhase.name.in_(exclude_phase_names)
)
.add_columns(
Event.id.label("event_id"),
Work.id.label("work_id"),
PhaseCode.name.label("phase_name"),
latest_status_updates.c.posted_date.label("date_updated"),
Expand Down Expand Up @@ -234,7 +239,34 @@ def generate_report(self, report_date, return_type):
"""Generates a report and returns it"""
current_app.logger.info(f"Generating {self.report_title} report for {report_date}")
data = self._fetch_data(report_date)
data = self._format_data(data)

works_list = []
for item in data:
current_app.logger.debug(f"Work ID: {item[0]}")
work_issues = db.session.query(WorkIssues).filter_by(work_id=item.work_id).all()
current_app.logger.debug(f"Work Issues: {work_issues}")
item_dict = item._asdict()
item_dict['work_issues'] = work_issues
works_list.append(item_dict)

# go through all the work issues, find the update and add the description to the issue
for issue in work_issues:
work_issue_updates = (
db.session.query(WorkIssueUpdates)
.filter_by(
work_issue_id=issue.id,
is_active=True,
is_approved=True
)
.order_by(WorkIssueUpdates.updated_at.desc())
.first()
)
if work_issue_updates:
for work_issue in item_dict['work_issues']:
if work_issue.id == issue.id:
work_issue.description = work_issue_updates.description

data = self._format_data(works_list)
data = self._update_staleness(data, report_date)

if return_type == "json" or not data:
Expand Down
20 changes: 18 additions & 2 deletions epictrack-api/src/api/reports/report_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from io import BytesIO
from pathlib import Path
from sqlalchemy import and_, func

from flask import current_app
from api.models import WorkStatus, db


Expand Down Expand Up @@ -36,7 +36,8 @@ def _format_data(self, data):
excluded_items = self.filters["exclude"]
for item in data:
obj = {
k: getattr(item, k) for k in self.data_keys if k not in excluded_items
k: (item[k] if k != "work_issues" else self._deserialize_work_issues(item[k]))
for k in self.data_keys if k not in excluded_items
}
if self.group_by:
obj["sl_no"] = len(formatted_data[obj.get(self.group_by)]) + 1
Expand All @@ -45,6 +46,21 @@ def _format_data(self, data):
formatted_data.append(obj)
return formatted_data

def _deserialize_work_issues(self, work_issues):
"""Deserialize work issues from the database format to a report-friendly format."""
current_app.logger.debug(f"Deserializing work issues: {work_issues}")
deserialized_issues = []
for issue in work_issues:
deserialized_issues.append({
"id": issue.id,
"title": issue.title,
"description": issue.description if hasattr(issue, 'description') else None,
"is_high_priority": issue.is_high_priority,
"created_at": issue.created_at.strftime("%Y-%m-%d %H:%M:%S") if issue.created_at else None,
"updated_at": issue.updated_at.strftime("%Y-%m-%d %H:%M:%S") if issue.updated_at else None,
})
return deserialized_issues

@abstractmethod
def generate_report(self, report_date, return_type):
"""Generates a report and returns it"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,8 @@ import {
MILESTONE_TYPES,
} from "../../../constants/application-constant";
import { dateUtils } from "../../../utils";
import moment from "moment";
import ReportHeader from "../shared/report-header/ReportHeader";
import { ETPageContainer } from "../../shared";
import { Palette } from "styles/theme";
import { staleLevel } from "utils/uiUtils";

export default function AnticipatedEAOSchedule() {
Expand Down Expand Up @@ -231,6 +229,7 @@ export default function AnticipatedEAOSchedule() {
</AccordionSummary>
<AccordionDetails>
{((reports as any)[key] as []).map((item, itemIndex) => {
console.log(item);
return (
<Accordion key={itemIndex} elevation={0}>
<AccordionSummary
Expand Down Expand Up @@ -391,6 +390,25 @@ export default function AnticipatedEAOSchedule() {
{item["additional_info"]}
</TableCell>
</TableRow>
{item["work_issues"] &&
(item["work_issues"] as any[]).map(
(issue, issueIndex) => {
if (issue.is_high_priority) {
return (
<TableRow key={issueIndex}>
<TableCell>
High Priority Issue
</TableCell>
<TableCell>
{issue.title}:
{issue.description}
</TableCell>
</TableRow>
);
}
return null;
}
)}
</TableBody>
</Table>
</TabPanel>
Expand Down

0 comments on commit 302f4b2

Please sign in to comment.