Removed None id's from plays
This commit is contained in:
parent
746f7fb4a7
commit
fc551be2a4
2 changed files with 7 additions and 1 deletions
|
|
@ -41,7 +41,7 @@ def get_multiple_boardgames(boardgame_ids: list[int]) -> list[boardgame_classes.
|
||||||
|
|
||||||
def divide_list_in_chunks(list_to_divide: list[int], chunk_size: int = definitions.BGG_MAX_THING_BOARDGAMES):
|
def divide_list_in_chunks(list_to_divide: list[int], chunk_size: int = definitions.BGG_MAX_THING_BOARDGAMES):
|
||||||
for i in range(0, len(list_to_divide), chunk_size):
|
for i in range(0, len(list_to_divide), chunk_size):
|
||||||
yield list_to_divide[i:i + chunk_size]
|
yield list_to_divide[i:i + chunk_size]
|
||||||
|
|
||||||
|
|
||||||
boardgame_list_to_return: list[boardgame_classes.BoardGame] = []
|
boardgame_list_to_return: list[boardgame_classes.BoardGame] = []
|
||||||
|
|
|
||||||
|
|
@ -95,6 +95,12 @@ def get_plays(session: Session) -> list[play_classes.Play]:
|
||||||
#list + set to remove duplicates
|
#list + set to remove duplicates
|
||||||
played_boardgame_ids = list(set([play.boardgame_id for play in plays_from_db]))
|
played_boardgame_ids = list(set([play.boardgame_id for play in plays_from_db]))
|
||||||
played_expansion_ids = list(set([play.expansion_id for play in plays_from_db]))
|
played_expansion_ids = list(set([play.expansion_id for play in plays_from_db]))
|
||||||
|
|
||||||
|
#Remove None's (played board games don't have expansion id and vice versa)
|
||||||
|
played_boardgame_ids = list(filter(lambda x: x != None, played_boardgame_ids))
|
||||||
|
played_expansion_ids = list(filter(lambda x: x != None, played_expansion_ids))
|
||||||
|
|
||||||
|
assert len(list(filter(lambda x: x == None, played_boardgame_ids))) == 0, plays_from_db
|
||||||
|
|
||||||
get_multiple_boardgames(get_db_session(), played_boardgame_ids + played_expansion_ids)
|
get_multiple_boardgames(get_db_session(), played_boardgame_ids + played_expansion_ids)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue