From 6be31c31630ee7857e3131ceddeb8e979bc7ed4a Mon Sep 17 00:00:00 2001 From: Connor Bechthold Date: Sat, 20 Apr 2024 22:58:33 -0400 Subject: [PATCH] run the linter --- .../implementations/log_records_service.py | 11 +++++--- ...e9_create_log_records_attn_to_junction_.py | 27 ++++++++++++------- frontend/src/components/forms/ViewLog.tsx | 4 +-- .../pages/HomePage/LogRecordsTable.tsx | 27 ++++++++++++------- frontend/src/helper/csvHelpers.ts | 3 ++- 5 files changed, 46 insertions(+), 26 deletions(-) diff --git a/backend/app/services/implementations/log_records_service.py b/backend/app/services/implementations/log_records_service.py index fcfd95b1..2cb9a871 100644 --- a/backend/app/services/implementations/log_records_service.py +++ b/backend/app/services/implementations/log_records_service.py @@ -74,7 +74,9 @@ def construct_attn_tos(self, log_record, attn_tos): attn_to = User.query.filter_by(id=attn_to_id).first() if not attn_to: - raise Exception(f"Employee (attn_to) with id {attn_to_id} does not exist") + raise Exception( + f"Employee (attn_to) with id {attn_to_id} does not exist" + ) log_record.attn_tos.append(attn_to) def to_json_list(self, logs): @@ -132,7 +134,9 @@ def filter_by_attn_tos(self, attn_tos): if type(attn_tos) == list: sql_statement = f"\n'{attn_tos[0]}'=ANY (attn_to_ids)" for i in range(1, len(attn_tos)): - sql_statement = sql_statement + f"\nAND '{attn_tos[i]}'=ANY (attn_to_ids)" + sql_statement = ( + sql_statement + f"\nAND '{attn_tos[i]}'=ANY (attn_to_ids)" + ) return sql_statement return f"\n'{attn_tos}'=ANY (attn_to_ids)" @@ -213,7 +217,7 @@ def join_tag_attributes(self): JOIN tags ON lrt.tag_id = tags.tag_id\n \ GROUP BY logs.log_id \n \ ) t ON logs.log_id = t.log_id\n" - + def join_attn_to_attributes(self): return "\nLEFT JOIN\n \ (SELECT logs.log_id, ARRAY_AGG(users.id) AS attn_to_ids, ARRAY_AGG(CONCAT(users.first_name, ' ', users.last_name)) AS attn_to_names FROM log_records logs\n \ @@ -304,7 +308,6 @@ def delete_log_record(self, log_id): db.session.commit() def update_log_record(self, log_id, updated_log_record): - log_record = LogRecords.query.filter_by(log_id=log_id).first() if log_record: log_record.residents = [] diff --git a/backend/migrations/versions/51ad56d133e9_create_log_records_attn_to_junction_.py b/backend/migrations/versions/51ad56d133e9_create_log_records_attn_to_junction_.py index 02042ab4..4d338d55 100644 --- a/backend/migrations/versions/51ad56d133e9_create_log_records_attn_to_junction_.py +++ b/backend/migrations/versions/51ad56d133e9_create_log_records_attn_to_junction_.py @@ -10,26 +10,33 @@ # revision identifiers, used by Alembic. -revision = '51ad56d133e9' -down_revision = 'eff8a5a7fda3' +revision = "51ad56d133e9" +down_revision = "eff8a5a7fda3" branch_labels = None depends_on = None def upgrade(): # ### commands auto generated by Alembic - please adjust! ### - op.create_table('log_record_attn_tos', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('log_record_id', sa.Integer(), nullable=False), - sa.Column('attn_to_id', sa.Integer(), nullable=False), - sa.ForeignKeyConstraint(['attn_to_id'], ['users.id'], ), - sa.ForeignKeyConstraint(['log_record_id'], ['log_records.log_id'], ), - sa.PrimaryKeyConstraint('id') + op.create_table( + "log_record_attn_tos", + sa.Column("id", sa.Integer(), nullable=False), + sa.Column("log_record_id", sa.Integer(), nullable=False), + sa.Column("attn_to_id", sa.Integer(), nullable=False), + sa.ForeignKeyConstraint( + ["attn_to_id"], + ["users.id"], + ), + sa.ForeignKeyConstraint( + ["log_record_id"], + ["log_records.log_id"], + ), + sa.PrimaryKeyConstraint("id"), ) # ### end Alembic commands ### def downgrade(): # ### commands auto generated by Alembic - please adjust! ### - op.drop_table('log_record_attn_tos') + op.drop_table("log_record_attn_tos") # ### end Alembic commands ### diff --git a/frontend/src/components/forms/ViewLog.tsx b/frontend/src/components/forms/ViewLog.tsx index 01be84ef..5c94c7f0 100644 --- a/frontend/src/components/forms/ViewLog.tsx +++ b/frontend/src/components/forms/ViewLog.tsx @@ -169,8 +169,8 @@ const ViewLog = ({ MultiValueRemove: () => null, }} placeholder="No Attn Tos" - defaultValue={employeeOptions.filter((item) => - logRecord.attnTos.includes(item.label) + defaultValue={employeeOptions.filter((item) => + logRecord.attnTos.includes(item.label), )} styles={viewStyle} /> diff --git a/frontend/src/components/pages/HomePage/LogRecordsTable.tsx b/frontend/src/components/pages/HomePage/LogRecordsTable.tsx index cb373b9a..1fda8fc4 100644 --- a/frontend/src/components/pages/HomePage/LogRecordsTable.tsx +++ b/frontend/src/components/pages/HomePage/LogRecordsTable.tsx @@ -150,11 +150,10 @@ const LogRecordsTable = ({ const usersData = await UserAPIClient.getUsers({ returnAll: true }); if (usersData && usersData.users.length !== 0) { - const userLabels: SelectLabel[] = usersData.users - .map((user) => ({ - label: `${user.firstName} ${user.lastName}`, - value: user.id, - })); + const userLabels: SelectLabel[] = usersData.users.map((user) => ({ + label: `${user.firstName} ${user.lastName}`, + value: user.id, + })); setEmployeeOptions(userLabels); } @@ -254,17 +253,27 @@ const LogRecordsTable = ({ return ( <> - {date} - {time} + + {date} + + + {time} + {formatList(record.residents)} {formatNote(record.note)} - {`${record.employee.firstName}`} + {`${record.employee.firstName}`} - {formatList(record.attnTos.map((attnTo) => attnTo.split(" ")[0]))} + {formatList( + record.attnTos.map((attnTo) => attnTo.split(" ")[0]), + )} {formatList(record.tags)} diff --git a/frontend/src/helper/csvHelpers.ts b/frontend/src/helper/csvHelpers.ts index 4295d395..aadaa8a0 100644 --- a/frontend/src/helper/csvHelpers.ts +++ b/frontend/src/helper/csvHelpers.ts @@ -3,7 +3,8 @@ import { CSVLog } from "../types/CSVLogTypes"; const convertToCSVLog = (logRecord: LogRecord): CSVLog => { return { - attnTos: logRecord.attnTos != null ? `"${logRecord.attnTos.join(", ")}"` : "", + attnTos: + logRecord.attnTos != null ? `"${logRecord.attnTos.join(", ")}"` : "", building: `"${logRecord.building.name}"`, datetime: `"${logRecord.datetime}"`, employee: `"${logRecord.employee.firstName} ${logRecord.employee.lastName}"`,