Skip to content

Commit

Permalink
run the linter
Browse files Browse the repository at this point in the history
  • Loading branch information
Connor Bechthold committed Apr 21, 2024
1 parent 2d51191 commit 6be31c3
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 26 deletions.
11 changes: 7 additions & 4 deletions backend/app/services/implementations/log_records_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)"

Expand Down Expand Up @@ -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 \
Expand Down Expand Up @@ -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 = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 ###
4 changes: 2 additions & 2 deletions frontend/src/components/forms/ViewLog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}
/>
Expand Down
27 changes: 18 additions & 9 deletions frontend/src/components/pages/HomePage/LogRecordsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -254,17 +253,27 @@ const LogRecordsTable = ({
return (
<>
<Tr key={record.logId} style={{ verticalAlign: "middle" }}>
<Td whiteSpace="normal" wordBreak="keep-all" width="5%">{date}</Td>
<Td whiteSpace="normal" wordBreak="keep-all" width="5%">{time}</Td>
<Td whiteSpace="normal" wordBreak="keep-all" width="5%">
{date}
</Td>
<Td whiteSpace="normal" wordBreak="keep-all" width="5%">
{time}
</Td>
<Td whiteSpace="normal" wordBreak="keep-all" width="5%">
{formatList(record.residents)}
</Td>
<Td whiteSpace="normal" width="70%">
{formatNote(record.note)}
</Td>
<Td whiteSpace="normal" wordBreak="keep-all" width="5%">{`${record.employee.firstName}`}</Td>
<Td
whiteSpace="normal"
wordBreak="keep-all"
width="5%"
>{`${record.employee.firstName}`}</Td>
<Td whiteSpace="normal" wordBreak="keep-all" width="5%">
{formatList(record.attnTos.map((attnTo) => attnTo.split(" ")[0]))}
{formatList(
record.attnTos.map((attnTo) => attnTo.split(" ")[0]),
)}
</Td>
<Td whiteSpace="normal" wordBreak="keep-all" width="5%">
{formatList(record.tags)}
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/helper/csvHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}"`,
Expand Down

0 comments on commit 6be31c3

Please sign in to comment.