Skip to content

Commit

Permalink
Filter all name variants in one query (don't catch exceptions)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeydergunov committed Jan 5, 2025
1 parent 0534b9b commit 6e8b68b
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions server/rating/management/commands/update_trueskill.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,21 +63,14 @@ def get_rating_by_type(type):


def find_all_players(first_names: List[str], last_names: List[str]) -> List[Player]:
try:
players = []
players.extend(
Player.objects.filter(
first_name_ru__in=first_names, last_name_ru__in=last_names, is_exclude_from_rating=False
)
)
players.extend(
Player.objects.filter(
first_name_ru__in=last_names, last_name_ru__in=first_names, is_exclude_from_rating=False
)
)
return players
except (Player.DoesNotExist, Player.MultipleObjectsReturned):
return None
players = []
players.extend(
Player.objects.filter(first_name_ru__in=first_names, last_name_ru__in=last_names, is_exclude_from_rating=False)
)
players.extend(
Player.objects.filter(first_name_ru__in=last_names, last_name_ru__in=first_names, is_exclude_from_rating=False)
)
return players


def generate_name_variants(name: str) -> List[str]:
Expand Down

0 comments on commit 6e8b68b

Please sign in to comment.