Skip to content

Commit

Permalink
Merge pull request #2405 from tom0827/TRACK-11
Browse files Browse the repository at this point in the history
fix typos and filter in query
  • Loading branch information
tom0827 authored Sep 14, 2024
2 parents f981880 + 5a13b6d commit ad6f6e5
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 14 deletions.
5 changes: 2 additions & 3 deletions epictrack-api/src/api/models/work.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ def title(self):
return func.concat(Project.name, " - ", WorkType.name, " - ", self.simple_title) # pylint:disable=not-callable

@hybrid_property
def anticipated_refferal_date(self):
"""Dynamically create the anticipated refferal date."""
def anticipated_referral_date(self):
"""Dynamically create the anticipated referral date."""
return (
db.session.query(func.min(Event.anticipated_date).label("min_anticipated_date"))
.join(
Expand All @@ -159,7 +159,6 @@ def anticipated_refferal_date(self):
)
.filter(
Event.work_id == self.id,
Event.actual_date is None,
func.coalesce(Event.actual_date, Event.anticipated_date) >= datetime.today(),
)
.scalar()
Expand Down
9 changes: 4 additions & 5 deletions epictrack-api/src/api/schemas/response/work_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ class Meta(AutoSchemaBase.Meta):
decision_by = fields.Nested(StaffSchema, exclude=("position",), dump_only=True)
work_state = fields.Method("get_work_state")
indigenous_works = fields.List(fields.Nested(IndigenousWorkResponseSchema, dump_only=True))
anticipated_refferal_date = fields.Method("get_anticipated_refferal_date")

anticipated_referral_date = fields.Method("get_anticipated_referral_date")
title = fields.Method("get_title")

def get_work_state(self, obj: Work) -> str:
Expand All @@ -97,9 +96,9 @@ def get_title(self, obj: Work) -> str:
"""Return the title"""
return obj.title

def get_anticipated_refferal_date(self, obj) -> str:
"""Return the refferal date"""
return obj.anticipated_refferal_date if obj.anticipated_refferal_date else None
def get_anticipated_referral_date(self, obj) -> str:
"""Return the referral date"""
return obj.anticipated_referral_date if obj.anticipated_referral_date else None


class WorkStaffRoleReponseSchema(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ const mockWork = {
decision_maker_position_id: faker.number.int(),
start_date_locked: faker.datatype.boolean(),
created_at: faker.date.past().toISOString(),
anticipated_refferal_date: faker.date.future().toISOString(),
anticipated_referral_date: faker.date.future().toISOString(),
project: {
id: faker.number.int(),
name: faker.lorem.words(2),
Expand Down
2 changes: 1 addition & 1 deletion epictrack-web/src/components/work/__test__/WorkList.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ const generateMockWork = (): Work => {
decision_maker_position_id: faker.datatype.number(),
start_date_locked: faker.datatype.boolean(),
created_at: faker.date.past().toISOString(),
anticipated_refferal_date: faker.date.future().toISOString(),
anticipated_referral_date: faker.date.future().toISOString(),
project: {
created_at: faker.date.past().toISOString(),
description: faker.lorem.paragraph(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ describe("About", () => {
cy.get("p").contains(mockWork.decision_by.full_name).should("be.visible");
cy.get("p")
.contains(
dayjs(mockWork.anticipated_refferal_date).format(MONTH_DAY_YEAR)
dayjs(mockWork.anticipated_referral_date).format(MONTH_DAY_YEAR)
)
.should("be.visible");
cy.get("p")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ const WorkDetails = () => {
</Grid>
<Grid item xs={12}>
<ETParagraph color={Palette.neutral.dark}>
{work.anticipated_refferal_date
? dayjs(work.anticipated_refferal_date).format(MONTH_DAY_YEAR)
{work.anticipated_referral_date
? dayjs(work.anticipated_referral_date).format(MONTH_DAY_YEAR)
: "-"}
</ETParagraph>
</Grid>
Expand Down
2 changes: 1 addition & 1 deletion epictrack-web/src/models/work.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export interface Work extends MasterBase {
substitution_act: ListType;
eac_decision_by: Staff;
decision_by: Staff;
anticipated_refferal_date: string;
anticipated_referral_date: string;
indigenous_works?: {
id: number;
name: string;
Expand Down

0 comments on commit ad6f6e5

Please sign in to comment.