Skip to content

Commit

Permalink
Updates merge_employment_records to include Unit model
Browse files Browse the repository at this point in the history
  • Loading branch information
RyanPark44 committed Jun 11, 2024
1 parent 10edcac commit 8ad9a90
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 6 deletions.
5 changes: 1 addition & 4 deletions backend/database/models/employment.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ def get_highest_rank(records: list[Employment]):

def merge_employment_records(
records: list[Employment],
unit: str = None,
currently_employed: bool = None
):
"""
Expand All @@ -86,17 +85,15 @@ def merge_employment_records(
"""
earliest_employment, latest_employment = get_employment_range(records)
highest_rank = get_highest_rank(records)
if unit is None:
unit = records[0].unit
if currently_employed is None:
currently_employed = records[0].currently_employed
return Employment(
officer_id=records[0].officer_id,
agency_id=records[0].agency_id,
unit_id=records[0].unit_id,
badge_number=records[0].badge_number,
earliest_employment=earliest_employment,
latest_employment=latest_employment,
unit=unit,
highest_rank=highest_rank,
currently_employed=currently_employed,
)
1 change: 0 additions & 1 deletion backend/routes/agencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,6 @@ def add_officer_to_agency(agency_id: int):
employment.agency_id = agency_id
employment = merge_employment_records(
employments.all() + [employment],
unit=record.unit,
currently_employed=record.currently_employed
)

Expand Down
1 change: 0 additions & 1 deletion backend/routes/officers.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,6 @@ def update_employment(officer_id: int):
employment.officer_id = officer_id
employment = merge_employment_records(
employments.all() + [employment],
unit=record.unit,
currently_employed=record.currently_employed
)

Expand Down

0 comments on commit 8ad9a90

Please sign in to comment.