Skip to content

Commit

Permalink
Minor fix to command
Browse files Browse the repository at this point in the history
  • Loading branch information
aviupadhyayula committed Jan 29, 2025
1 parent 8daf05d commit 5536735
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions backend/clubs/management/commands/merge_duplicate_committees.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def handle(self, *args, **kwargs):
normalized_name=models.functions.Lower(
models.functions.Trim("name")
)
).values("name", "normalized_name", "application")
).values("normalized_name", "application")
if club_code is not None:
committees_query = committees_query.filter(

Check warning on line 39 in backend/clubs/management/commands/merge_duplicate_committees.py

View check run for this annotation

Codecov / codecov/patch

backend/clubs/management/commands/merge_duplicate_committees.py#L38-L39

Added lines #L38 - L39 were not covered by tests
application__club__code=club_code
Expand All @@ -46,20 +46,27 @@ def handle(self, *args, **kwargs):

total_merged = 0
for duplicate in duplicate_committees:
name = duplicate["name"]
normalized_name = duplicate["normalized_name"]
application_id = duplicate["application"]

Check warning on line 50 in backend/clubs/management/commands/merge_duplicate_committees.py

View check run for this annotation

Codecov / codecov/patch

backend/clubs/management/commands/merge_duplicate_committees.py#L47-L50

Added lines #L47 - L50 were not covered by tests

committees = ApplicationCommittee.objects.filter(
name=name, application=application_id
).order_by("id")
committees = (

Check warning on line 52 in backend/clubs/management/commands/merge_duplicate_committees.py

View check run for this annotation

Codecov / codecov/patch

backend/clubs/management/commands/merge_duplicate_committees.py#L52

Added line #L52 was not covered by tests
ApplicationCommittee.objects.filter(application=application_id)
.annotate(
normalized_name=models.functions.Lower(
models.functions.Trim("name")
)
)
.filter(normalized_name=normalized_name)
.order_by("id")
)

primary_committee = committees.first()
if not primary_committee:
continue

Check warning on line 65 in backend/clubs/management/commands/merge_duplicate_committees.py

View check run for this annotation

Codecov / codecov/patch

backend/clubs/management/commands/merge_duplicate_committees.py#L63-L65

Added lines #L63 - L65 were not covered by tests

self.stdout.write(

Check warning on line 67 in backend/clubs/management/commands/merge_duplicate_committees.py

View check run for this annotation

Codecov / codecov/patch

backend/clubs/management/commands/merge_duplicate_committees.py#L67

Added line #L67 was not covered by tests
f"Processing duplicate committees with name '{name}' "
f"in application {application_id}"
f"Processing duplicate committees with name "
f"'{normalized_name}' in application {application_id}"
)

# Merge all other committees into the primary one
Expand Down

0 comments on commit 5536735

Please sign in to comment.