From 5a13b6d035118c1842a29155b704cffb91bfe250 Mon Sep 17 00:00:00 2001 From: Tom Chapman Date: Wed, 11 Sep 2024 19:58:44 -0700 Subject: [PATCH] fix typos and filter in query --- epictrack-api/src/api/models/work.py | 5 ++--- epictrack-api/src/api/schemas/response/work_response.py | 9 ++++----- .../components/work/WorkForm/__test__/WorkForm.cy.tsx | 2 +- .../src/components/work/__test__/WorkList.cy.tsx | 2 +- .../aboutDetails/WorkDetails/__test__/WorkDetails.cy.tsx | 2 +- .../workPlan/about/aboutDetails/WorkDetails/index.tsx | 4 ++-- epictrack-web/src/models/work.ts | 2 +- 7 files changed, 12 insertions(+), 14 deletions(-) diff --git a/epictrack-api/src/api/models/work.py b/epictrack-api/src/api/models/work.py index 2efd6bd82..b97f5ca62 100644 --- a/epictrack-api/src/api/models/work.py +++ b/epictrack-api/src/api/models/work.py @@ -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( @@ -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() diff --git a/epictrack-api/src/api/schemas/response/work_response.py b/epictrack-api/src/api/schemas/response/work_response.py index e2e8358f6..67d1b3610 100644 --- a/epictrack-api/src/api/schemas/response/work_response.py +++ b/epictrack-api/src/api/schemas/response/work_response.py @@ -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: @@ -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( diff --git a/epictrack-web/src/components/work/WorkForm/__test__/WorkForm.cy.tsx b/epictrack-web/src/components/work/WorkForm/__test__/WorkForm.cy.tsx index 4dba4a5de..8deab258b 100644 --- a/epictrack-web/src/components/work/WorkForm/__test__/WorkForm.cy.tsx +++ b/epictrack-web/src/components/work/WorkForm/__test__/WorkForm.cy.tsx @@ -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), diff --git a/epictrack-web/src/components/work/__test__/WorkList.cy.tsx b/epictrack-web/src/components/work/__test__/WorkList.cy.tsx index 9b96564ed..a67098fd9 100644 --- a/epictrack-web/src/components/work/__test__/WorkList.cy.tsx +++ b/epictrack-web/src/components/work/__test__/WorkList.cy.tsx @@ -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(), diff --git a/epictrack-web/src/components/workPlan/about/aboutDetails/WorkDetails/__test__/WorkDetails.cy.tsx b/epictrack-web/src/components/workPlan/about/aboutDetails/WorkDetails/__test__/WorkDetails.cy.tsx index 2c3d12a10..db40bc17c 100644 --- a/epictrack-web/src/components/workPlan/about/aboutDetails/WorkDetails/__test__/WorkDetails.cy.tsx +++ b/epictrack-web/src/components/workPlan/about/aboutDetails/WorkDetails/__test__/WorkDetails.cy.tsx @@ -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") diff --git a/epictrack-web/src/components/workPlan/about/aboutDetails/WorkDetails/index.tsx b/epictrack-web/src/components/workPlan/about/aboutDetails/WorkDetails/index.tsx index a238e0fd9..c10dd0d3d 100644 --- a/epictrack-web/src/components/workPlan/about/aboutDetails/WorkDetails/index.tsx +++ b/epictrack-web/src/components/workPlan/about/aboutDetails/WorkDetails/index.tsx @@ -109,8 +109,8 @@ const WorkDetails = () => { - {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) : "-"} diff --git a/epictrack-web/src/models/work.ts b/epictrack-web/src/models/work.ts index 5aed7a36e..1c96166a5 100644 --- a/epictrack-web/src/models/work.ts +++ b/epictrack-web/src/models/work.ts @@ -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;