Owned collection is properly stored in db
This commit is contained in:
parent
c73d7b31ce
commit
3e9347d71c
3 changed files with 23 additions and 5 deletions
BIN
db/database.db
BIN
db/database.db
Binary file not shown.
|
|
@ -9,26 +9,32 @@ def get_boardgame(boardgame_id: int) -> boardgame_classes.BoardGame:
|
||||||
|
|
||||||
to_return_boardgame = None
|
to_return_boardgame = None
|
||||||
|
|
||||||
if len(boardgame_in_db) == 0:
|
if len(boardgame_in_db) != 0:
|
||||||
|
to_return_boardgame = boardgame_in_db[0]
|
||||||
|
else:
|
||||||
to_return_boardgame = bgg_connection.get_boardgame(boardgame_id)
|
to_return_boardgame = bgg_connection.get_boardgame(boardgame_id)
|
||||||
db_connection.add_boardgame(to_return_boardgame)
|
db_connection.add_boardgame(to_return_boardgame)
|
||||||
else:
|
|
||||||
to_return_boardgame = boardgame_in_db[0]
|
|
||||||
|
|
||||||
return to_return_boardgame
|
return to_return_boardgame
|
||||||
|
|
||||||
|
|
||||||
def get_user_owned_collection() -> list[boardgame_classes.BoardGame]:
|
def get_user_owned_collection() -> list[boardgame_classes.OwnedBoardGame]:
|
||||||
owned_boardgames_from_db = db_connection.get_all_owned_boardgames()
|
owned_boardgames_from_db = db_connection.get_all_owned_boardgames()
|
||||||
|
|
||||||
if len(owned_boardgames_from_db) != 0:
|
if len(owned_boardgames_from_db) != 0:
|
||||||
return owned_boardgames_from_db
|
return owned_boardgames_from_db
|
||||||
else:
|
else:
|
||||||
return bgg_connection.get_user_owned_collection()
|
owned_boardgames = bgg_connection.get_user_owned_collection()
|
||||||
|
for boardgame in owned_boardgames:
|
||||||
|
db_connection.add_boardgame(boardgame)
|
||||||
|
|
||||||
|
return owned_boardgames
|
||||||
|
|
||||||
|
|
||||||
def get_user_wishlist_collection() -> list[boardgame_classes.BoardGame]:
|
def get_user_wishlist_collection() -> list[boardgame_classes.BoardGame]:
|
||||||
|
|
||||||
|
owned_boardgames_from_db = db_connection.get_all_wishlisted_boardgames
|
||||||
|
|
||||||
return bgg_connection.get_user_wishlist_collection()
|
return bgg_connection.get_user_wishlist_collection()
|
||||||
|
|
||||||
def get_plays() -> list[play_classes.Play]:
|
def get_plays() -> list[play_classes.Play]:
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,18 @@ def get_all_owned_boardgames() -> list[boardgame_classes.OwnedBoardGame]:
|
||||||
|
|
||||||
return boardgame_list
|
return boardgame_list
|
||||||
|
|
||||||
|
def get_all_owned_boardgames_expansions() -> list[boardgame_classes.OwnedBoardGameExpansion]:
|
||||||
|
with Session(engine) as session:
|
||||||
|
statement = select(boardgame_classes.OwnedBoardGameExpansion)
|
||||||
|
results = session.exec(statement)
|
||||||
|
|
||||||
|
boardgame_list = results.all()
|
||||||
|
|
||||||
|
return boardgame_list
|
||||||
|
|
||||||
|
def get_all_wishlisted_boardgames() -> list[boardgame_classes.WishlistBoardGame]:
|
||||||
|
pass
|
||||||
|
|
||||||
def delete_database():
|
def delete_database():
|
||||||
os.remove(definitions.DATABASE_FILE_PATH)
|
os.remove(definitions.DATABASE_FILE_PATH)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue