Fixed wrong board game type being set on retrieving from BGG
This commit is contained in:
parent
f83d8eb897
commit
bb1f255c6c
3 changed files with 15 additions and 11 deletions
|
|
@ -41,7 +41,8 @@ def get_boardgame_by_id(id: int):
|
||||||
|
|
||||||
@app.get("/owned", response_model=list[Union[boardgame_classes.OwnedBoardGame, boardgame_classes.OwnedBoardGameExpansion]])
|
@app.get("/owned", response_model=list[Union[boardgame_classes.OwnedBoardGame, boardgame_classes.OwnedBoardGameExpansion]])
|
||||||
def get_owned_collection():
|
def get_owned_collection():
|
||||||
return data_connection.get_user_owned_collection()
|
to_return_boardgames = data_connection.get_user_owned_collection()
|
||||||
|
return to_return_boardgames
|
||||||
|
|
||||||
|
|
||||||
@app.get("/wishlist", response_model=list[Union[boardgame_classes.WishlistBoardGame, boardgame_classes.WishlistBoardGameExpansion]])
|
@app.get("/wishlist", response_model=list[Union[boardgame_classes.WishlistBoardGame, boardgame_classes.WishlistBoardGameExpansion]])
|
||||||
|
|
|
||||||
|
|
@ -241,12 +241,13 @@ def get_boardgames_from_collection_url(collection_url: str, boardgame_type: boar
|
||||||
boardgame = convert_collection_xml_to_wishlist_boardgame(boardgame_extra, boardgame_item)
|
boardgame = convert_collection_xml_to_wishlist_boardgame(boardgame_extra, boardgame_item)
|
||||||
case boardgame_classes.BoardgameType.WISHLISTBOARDGAMEEXPANSION:
|
case boardgame_classes.BoardgameType.WISHLISTBOARDGAMEEXPANSION:
|
||||||
boardgame = convert_collection_xml_to_wishlist_boardgame(boardgame_extra, boardgame_item)
|
boardgame = convert_collection_xml_to_wishlist_boardgame(boardgame_extra, boardgame_item)
|
||||||
|
boardgame.type = boardgame_type
|
||||||
collection_list.append(boardgame)
|
collection_list.append(boardgame)
|
||||||
current_index += 1
|
current_index += 1
|
||||||
|
|
||||||
return collection_list
|
return collection_list
|
||||||
|
|
||||||
def get_user_owned_collection() -> list[boardgame_classes.BoardGame]:
|
def get_user_owned_collection() -> Union[list[boardgame_classes.OwnedBoardGame], list[boardgame_classes.OwnedBoardGameExpansion]]:
|
||||||
url_no_expansions = 'https://boardgamegeek.com/xmlapi2/collection?username={}&own=1&stats=1&excludesubtype=boardgameexpansion&showprivate=1&version=1'.format(auth_manager.username)
|
url_no_expansions = 'https://boardgamegeek.com/xmlapi2/collection?username={}&own=1&stats=1&excludesubtype=boardgameexpansion&showprivate=1&version=1'.format(auth_manager.username)
|
||||||
url_only_expansions = 'https://boardgamegeek.com/xmlapi2/collection?username={}&own=1&stats=1&subtype=boardgameexpansion&showprivate=1&version=1'.format(auth_manager.username)
|
url_only_expansions = 'https://boardgamegeek.com/xmlapi2/collection?username={}&own=1&stats=1&subtype=boardgameexpansion&showprivate=1&version=1'.format(auth_manager.username)
|
||||||
|
|
||||||
|
|
@ -257,7 +258,7 @@ def get_user_owned_collection() -> list[boardgame_classes.BoardGame]:
|
||||||
|
|
||||||
return owned_boardgames
|
return owned_boardgames
|
||||||
|
|
||||||
def get_user_wishlist_collection() -> list[boardgame_classes.BoardGame]:
|
def get_user_wishlist_collection() -> Union[list[boardgame_classes.WishlistBoardGame], list[boardgame_classes.WishlistBoardGameExpansion]]:
|
||||||
url_no_expanions = 'https://boardgamegeek.com/xmlapi2/collection?username={}&wishlist=1&stats=1&excludesubtype=boardgameexpansion&showprivate=1&version=1'.format(auth_manager.username)
|
url_no_expanions = 'https://boardgamegeek.com/xmlapi2/collection?username={}&wishlist=1&stats=1&excludesubtype=boardgameexpansion&showprivate=1&version=1'.format(auth_manager.username)
|
||||||
url_only_expansions = 'https://boardgamegeek.com/xmlapi2/collection?username={}&wishlist=1&stats=1&subtype=boardgameexpansion&showprivate=1&version=1'.format(auth_manager.username)
|
url_only_expansions = 'https://boardgamegeek.com/xmlapi2/collection?username={}&wishlist=1&stats=1&subtype=boardgameexpansion&showprivate=1&version=1'.format(auth_manager.username)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,17 +21,21 @@ def get_boardgame(boardgame_id: int) -> boardgame_classes.BoardGame:
|
||||||
|
|
||||||
|
|
||||||
def get_user_owned_collection() -> list[Union[boardgame_classes.OwnedBoardGame, boardgame_classes.OwnedBoardGameExpansion]]:
|
def get_user_owned_collection() -> list[Union[boardgame_classes.OwnedBoardGame, boardgame_classes.OwnedBoardGameExpansion]]:
|
||||||
owned_boardgames_from_db = db_connection.get_boardgames(boardgame_classes.OwnedBoardGame)
|
owned_boardgames_from_db: list[boardgame_classes.OwnedBoardGame] = db_connection.get_boardgames(boardgame_classes.OwnedBoardGame)
|
||||||
owned_boardgame_expanions_from_db = db_connection.get_boardgames(boardgame_classes.OwnedBoardGameExpansion)
|
owned_boardgame_expanions_from_db: list[boardgame_classes.OwnedBoardGameExpansion] = db_connection.get_boardgames(boardgame_classes.OwnedBoardGameExpansion)
|
||||||
|
|
||||||
|
to_return_boardgames = []
|
||||||
|
|
||||||
if len(owned_boardgames_from_db) == 0 and len(owned_boardgame_expanions_from_db) == 0:
|
if len(owned_boardgames_from_db) == 0 and len(owned_boardgame_expanions_from_db) == 0:
|
||||||
owned_boardgames = bgg_connection.get_user_owned_collection()
|
owned_boardgames = bgg_connection.get_user_owned_collection()
|
||||||
for boardgame in owned_boardgames:
|
for boardgame in owned_boardgames:
|
||||||
db_connection.add_boardgame(boardgame)
|
db_connection.add_boardgame(boardgame)
|
||||||
|
|
||||||
return owned_boardgames
|
to_return_boardgames = owned_boardgames
|
||||||
else:
|
else:
|
||||||
return owned_boardgames_from_db + owned_boardgame_expanions_from_db
|
to_return_boardgames = owned_boardgames_from_db + owned_boardgame_expanions_from_db
|
||||||
|
|
||||||
|
return to_return_boardgames
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -56,8 +60,6 @@ def get_user_wishlist_collection(wishlist_priority: int = 0) -> Union[list[board
|
||||||
if wishlist_priority != 0:
|
if wishlist_priority != 0:
|
||||||
to_return_boardgames = filter(lambda game: game.wishlist_priority == wishlist_priority, to_return_boardgames)
|
to_return_boardgames = filter(lambda game: game.wishlist_priority == wishlist_priority, to_return_boardgames)
|
||||||
|
|
||||||
print(to_return_boardgames)
|
|
||||||
|
|
||||||
return to_return_boardgames
|
return to_return_boardgames
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue