From 01882e08f32842096373e2d1fed685b91a284a32 Mon Sep 17 00:00:00 2001 From: Tom Chapman Date: Sat, 14 Sep 2024 19:39:45 -0700 Subject: [PATCH 1/4] fix reports getting old epd/lead --- ...a3fafa6f1b_set_new_work_types_to_active.py | 31 +++++++++++++++++++ .../api/reports/resource_forecast_report.py | 1 + 2 files changed, 32 insertions(+) create mode 100644 epictrack-api/migrations/versions/b7a3fafa6f1b_set_new_work_types_to_active.py diff --git a/epictrack-api/migrations/versions/b7a3fafa6f1b_set_new_work_types_to_active.py b/epictrack-api/migrations/versions/b7a3fafa6f1b_set_new_work_types_to_active.py new file mode 100644 index 000000000..ef17bff0c --- /dev/null +++ b/epictrack-api/migrations/versions/b7a3fafa6f1b_set_new_work_types_to_active.py @@ -0,0 +1,31 @@ +"""set new work_types to active + +Revision ID: b7a3fafa6f1b +Revises: c3af13f44bed +Create Date: 2024-09-14 15:39:51.264872 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = 'b7a3fafa6f1b' +down_revision = 'c3af13f44bed' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.execute("UPDATE work_types SET is_active = true WHERE name = 'EAC Extension'") + op.execute("UPDATE work_types SET is_active = true WHERE name = 'EAC/Order Transfer'") + op.execute("UPDATE work_types SET name = 'Substantial Start Determination' WHERE name = 'Substantial Start Decision'") + op.execute("UPDATE work_types SET is_active = true WHERE name = 'Substantial Start Determination'") + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + pass + # ### end Alembic commands ### \ No newline at end of file diff --git a/epictrack-api/src/api/reports/resource_forecast_report.py b/epictrack-api/src/api/reports/resource_forecast_report.py index d36cb9e4c..49463ea64 100644 --- a/epictrack-api/src/api/reports/resource_forecast_report.py +++ b/epictrack-api/src/api/reports/resource_forecast_report.py @@ -694,6 +694,7 @@ def _get_work_team_members(self, work_id) -> Tuple[List[str], str]: work_team_members = ( db.session.query(StaffWorkRole) .filter(StaffWorkRole.work_id == work_id) + .filter(StaffWorkRole.is_active == True) .join(Staff, Staff.id == StaffWorkRole.staff_id) .add_columns( Staff.first_name.label("first_name"), From a41ee14b8b000fc4b307ae31f30a816f2320138b Mon Sep 17 00:00:00 2001 From: Tom Chapman Date: Sat, 14 Sep 2024 19:44:17 -0700 Subject: [PATCH 2/4] combined migration lines --- .../versions/b7a3fafa6f1b_set_new_work_types_to_active.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/epictrack-api/migrations/versions/b7a3fafa6f1b_set_new_work_types_to_active.py b/epictrack-api/migrations/versions/b7a3fafa6f1b_set_new_work_types_to_active.py index ef17bff0c..e3dc7c84b 100644 --- a/epictrack-api/migrations/versions/b7a3fafa6f1b_set_new_work_types_to_active.py +++ b/epictrack-api/migrations/versions/b7a3fafa6f1b_set_new_work_types_to_active.py @@ -20,8 +20,7 @@ def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.execute("UPDATE work_types SET is_active = true WHERE name = 'EAC Extension'") op.execute("UPDATE work_types SET is_active = true WHERE name = 'EAC/Order Transfer'") - op.execute("UPDATE work_types SET name = 'Substantial Start Determination' WHERE name = 'Substantial Start Decision'") - op.execute("UPDATE work_types SET is_active = true WHERE name = 'Substantial Start Determination'") + op.execute("UPDATE work_types SET name = 'Substantial Start Determination', is_active = true WHERE name = 'Substantial Start Decision'") # ### end Alembic commands ### From 9d2c015786ebcfd67358808e0688eb29fcafdebd Mon Sep 17 00:00:00 2001 From: Tom Chapman Date: Fri, 20 Sep 2024 10:54:56 -0700 Subject: [PATCH 3/4] linting --- epictrack-api/src/api/reports/resource_forecast_report.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/epictrack-api/src/api/reports/resource_forecast_report.py b/epictrack-api/src/api/reports/resource_forecast_report.py index 49463ea64..fa6fd8afa 100644 --- a/epictrack-api/src/api/reports/resource_forecast_report.py +++ b/epictrack-api/src/api/reports/resource_forecast_report.py @@ -694,7 +694,7 @@ def _get_work_team_members(self, work_id) -> Tuple[List[str], str]: work_team_members = ( db.session.query(StaffWorkRole) .filter(StaffWorkRole.work_id == work_id) - .filter(StaffWorkRole.is_active == True) + .filter(bool(StaffWorkRole.is_active) == True) .join(Staff, Staff.id == StaffWorkRole.staff_id) .add_columns( Staff.first_name.label("first_name"), From f522be1b3eed722cd19acee51050da6e061a879c Mon Sep 17 00:00:00 2001 From: Tom Chapman Date: Fri, 20 Sep 2024 11:02:41 -0700 Subject: [PATCH 4/4] linting --- epictrack-api/src/api/reports/resource_forecast_report.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/epictrack-api/src/api/reports/resource_forecast_report.py b/epictrack-api/src/api/reports/resource_forecast_report.py index fa6fd8afa..23a42f0f5 100644 --- a/epictrack-api/src/api/reports/resource_forecast_report.py +++ b/epictrack-api/src/api/reports/resource_forecast_report.py @@ -694,7 +694,7 @@ def _get_work_team_members(self, work_id) -> Tuple[List[str], str]: work_team_members = ( db.session.query(StaffWorkRole) .filter(StaffWorkRole.work_id == work_id) - .filter(bool(StaffWorkRole.is_active) == True) + .filter(StaffWorkRole.is_active.is_(True)) .join(Staff, Staff.id == StaffWorkRole.staff_id) .add_columns( Staff.first_name.label("first_name"),