Fixed version info not updating if boardgame is already present
This commit is contained in:
parent
4c0a3ec600
commit
c6075b7949
3 changed files with 6 additions and 30 deletions
|
|
@ -10,7 +10,7 @@ class Designer(SQLModel, table=True):
|
||||||
|
|
||||||
class DesignerPublic(SQLModel):
|
class DesignerPublic(SQLModel):
|
||||||
name: str
|
name: str
|
||||||
designed_boardgames: list[boardgame_classes.BoardGamePublic]
|
designed_boardgames: list[boardgame_classes.BoardGamePublicNoPlays]
|
||||||
|
|
||||||
class DesignerPublicNoGames(SQLModel):
|
class DesignerPublicNoGames(SQLModel):
|
||||||
name: str
|
name: str
|
||||||
|
|
@ -10,7 +10,6 @@ def filter_expansions_out(to_filter_boardgames: list[boardgame_classes.BoardGame
|
||||||
|
|
||||||
def filter_non_expansions_out(to_filter_boardgames: list[boardgame_classes.BoardGame]):
|
def filter_non_expansions_out(to_filter_boardgames: list[boardgame_classes.BoardGame]):
|
||||||
|
|
||||||
|
|
||||||
filtered_boardgames = list(filter(lambda x: x.expansion_info != None, to_filter_boardgames))
|
filtered_boardgames = list(filter(lambda x: x.expansion_info != None, to_filter_boardgames))
|
||||||
|
|
||||||
return filtered_boardgames
|
return filtered_boardgames
|
||||||
|
|
@ -52,6 +52,11 @@ def upsert_multiple_boardgames(session: Session, boardgame_list: list[boardgame_
|
||||||
wishlist_info = new_db_boardgame.wishlist_info.model_dump()
|
wishlist_info = new_db_boardgame.wishlist_info.model_dump()
|
||||||
db_boardgame.wishlist_info = boardgame_classes.WishlistInfo(**wishlist_info)
|
db_boardgame.wishlist_info = boardgame_classes.WishlistInfo(**wishlist_info)
|
||||||
|
|
||||||
|
db_boardgame.name = new_db_boardgame.name
|
||||||
|
db_boardgame.image_url = new_db_boardgame.image_url
|
||||||
|
db_boardgame.thumbnail_url = new_db_boardgame.thumbnail_url
|
||||||
|
db_boardgame.year_published = new_db_boardgame.year_published
|
||||||
|
|
||||||
return db_boardgame
|
return db_boardgame
|
||||||
|
|
||||||
with critical_function_lock:
|
with critical_function_lock:
|
||||||
|
|
@ -87,34 +92,6 @@ def upsert_multiple_boardgames(session: Session, boardgame_list: list[boardgame_
|
||||||
|
|
||||||
session.commit()
|
session.commit()
|
||||||
|
|
||||||
# for boardgame_index in range(len(boardgame_list)):
|
|
||||||
# #Check if boardgame is already present
|
|
||||||
|
|
||||||
# if boardgame_list[boardgame_index] in existing_boardgames:
|
|
||||||
# to_alter_boardgame = update_boardgame(list(filter(lambda x: x.id == boardgame_list[boardgame_index].id, existing_boardgames))[0], boardgame_list[boardgame_index])
|
|
||||||
# else:
|
|
||||||
# to_alter_boardgame = insert_boardgame(boardgame_list[boardgame_index])
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# # if not is_boardgame_present:
|
|
||||||
# # to_alter_boardgame = boardgame_list[boardgame_index]
|
|
||||||
# # else:
|
|
||||||
# # to_alter_boardgame = present_boardgames[0]
|
|
||||||
# # copy_attributes_from_to(boardgame_list[boardgame_index],to_alter_boardgame)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# # statement = select(boardgame_classes.BoardGame).where(boardgame_classes.BoardGame.id == to_alter_boardgame.id)
|
|
||||||
# # present_boardgames = session.exec(statement).all()
|
|
||||||
# # is_boardgame_present = len(present_boardgames) != 0
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# session.add(to_alter_boardgame)
|
|
||||||
# altered_boardgames.append(to_alter_boardgame)
|
|
||||||
|
|
||||||
[session.refresh(boardgame) for boardgame in altered_boardgames]
|
[session.refresh(boardgame) for boardgame in altered_boardgames]
|
||||||
|
|
||||||
def get_designer(session: Session, designer_id: int) -> people_classes.Designer:
|
def get_designer(session: Session, designer_id: int) -> people_classes.Designer:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue