Use version info for owned & wishlisted board games

This commit is contained in:
Yarne Coppens 2024-08-22 21:24:01 +02:00
parent fde850d13a
commit 6f5436e653
2 changed files with 16 additions and 22 deletions

View file

@ -123,8 +123,6 @@ def convert_xml_to_boardgame(boardgame_xml: ET.Element) -> boardgame_classes.Boa
def convert_collection_xml_to_owned_boardgame(boardgame_extra_info: boardgame_classes.BoardGame, collection_boardgame_xml: ET.Element) -> boardgame_classes.BoardGame: def convert_collection_xml_to_owned_boardgame(boardgame_extra_info: boardgame_classes.BoardGame, collection_boardgame_xml: ET.Element) -> boardgame_classes.BoardGame:
boardgame_type = collection_boardgame_xml.get('subtype')
price_paid = collection_boardgame_xml.find('privateinfo').get('pricepaid') price_paid = collection_boardgame_xml.find('privateinfo').get('pricepaid')
if price_paid == '': if price_paid == '':
price_paid = 0.0 price_paid = 0.0
@ -152,13 +150,14 @@ def convert_collection_xml_to_owned_boardgame(boardgame_extra_info: boardgame_cl
boardgame_extra_info.owned_info = owned_info boardgame_extra_info.owned_info = owned_info
# if boardgame_type == "boardgameexpansion": boardgame_version_info = collection_boardgame_xml.find('version')
# expansion_boardgame_dict = {
# "boardgame_id" : boardgame_extra_info.id, if boardgame_version_info != None:
# "expansion_for" : boardgame_extra_info.expansion_for boardgame_extra_info_item = boardgame_version_info.find('item')
# } boardgame_extra_info.name = collection_boardgame_xml.find('name').text if boardgame_extra_info_item.find('name') != None else boardgame_extra_info.name
# expansion_info = boardgame_classes.ExpansionInfo.model_validate(expansion_boardgame_dict) boardgame_extra_info.image_url = boardgame_extra_info_item.find('image').text if boardgame_extra_info_item.find('image') != None else boardgame_extra_info.image_url
# boardgame_extra_info.expansion_info = expansion_info boardgame_extra_info.thumbnail_url = boardgame_extra_info_item.find('thumbnail').text if boardgame_extra_info_item.find('thumbnail') != None else boardgame_extra_info.thumbnail_url
boardgame_extra_info.year_published = boardgame_extra_info_item.find('yearpublished').get('value') if boardgame_extra_info_item.find('yearpublished') != None else boardgame_extra_info.year_published
boardgame = boardgame_extra_info boardgame = boardgame_extra_info
@ -166,8 +165,6 @@ def convert_collection_xml_to_owned_boardgame(boardgame_extra_info: boardgame_cl
def convert_collection_xml_to_wishlist_boardgame(boardgame_extra_info: boardgame_classes.BoardGame, collection_boardgame_xml: ET.Element) -> boardgame_classes.BoardGame: def convert_collection_xml_to_wishlist_boardgame(boardgame_extra_info: boardgame_classes.BoardGame, collection_boardgame_xml: ET.Element) -> boardgame_classes.BoardGame:
boardgame_type = collection_boardgame_xml.get('subtype')
wishlist_priority = collection_boardgame_xml.find('status').get('wishlistpriority') wishlist_priority = collection_boardgame_xml.find('status').get('wishlistpriority')
wishlist_boardgame_dict = { wishlist_boardgame_dict = {
@ -178,17 +175,14 @@ def convert_collection_xml_to_wishlist_boardgame(boardgame_extra_info: boardgame
boardgame_extra_info.wishlist_info = wishlist_info boardgame_extra_info.wishlist_info = wishlist_info
# boardgame_dict = { boardgame_version_info = collection_boardgame_xml.find('version')
# **boardgame_extra_info.__dict__,
# **wishlist_boardgame_dict
# }
# match boardgame_type: if boardgame_version_info != None:
# case "boardgame": boardgame_extra_info_item = boardgame_version_info.find('item')
# boardgame = boardgame_classes.WishlistBoardGame(**boardgame_dict) boardgame_extra_info.name = collection_boardgame_xml.find('name').text if boardgame_extra_info_item.find('name') != None else boardgame_extra_info.name
# case "boardgameexpansion": boardgame_extra_info.image_url = boardgame_extra_info_item.find('image').text if boardgame_extra_info_item.find('image') != None else boardgame_extra_info.image_url
# boardgame_dict['expansion_for'] = boardgame_extra_info.expansion_for boardgame_extra_info.thumbnail_url = boardgame_extra_info_item.find('thumbnail').text if boardgame_extra_info_item.find('thumbnail') != None else boardgame_extra_info.thumbnail_url
# boardgame = boardgame_classes.WishlistBoardGameExpansion(**boardgame_dict) boardgame_extra_info.year_published = boardgame_extra_info_item.find('yearpublished').get('value') if boardgame_extra_info_item.find('yearpublished') != None else boardgame_extra_info.year_published
boardgame = boardgame_extra_info boardgame = boardgame_extra_info

View file

@ -125,4 +125,4 @@ def test_retrieve_game_order_statistic():
default_statistic_test(returned_statistic) default_statistic_test(returned_statistic)
assert type(returned_statistic.result) == list assert type(returned_statistic.result) == list
assert type(returned_statistic.result[0]) == boardgame_classes.BoardGame assert type(returned_statistic.result[0]) == boardgame_classes.BoardGamePublic