Added collection cost statistic

This commit is contained in:
Yarne Coppens 2024-08-15 19:47:30 +02:00
parent eafb2b386f
commit 1579666db4

View file

@ -139,6 +139,24 @@ def get_amount_of_games(query: BoardgameFilterParams = Depends(), session: Sessi
return statistic_to_return
@app.get('/statistics/total_collection_cost', response_model=statistic_classes.NumberStatistic)
def get_total_collection_cost(query: BoardgameFilterParams = Depends(), session: Session = Depends(get_session)):
owned_collection = data_connection.get_user_owned_collection(session)
owned_collection = query.do_filtering(owned_collection)
total_cost = sum([boardgame.price_paid for boardgame in owned_collection])
statistic_dict = {
"name":"Total cost of the owned collection",
"result":total_cost
}
statistic_to_return = statistic_classes.NumberStatistic(**statistic_dict)
return statistic_to_return
@app.get('/statistics/amount_of_games_over_time', response_model=statistic_classes.TimeLineStatistic)
def get_amount_of_games_over_time(query: BoardgameFilterParams = Depends(), day_step: int = 1, filter_expansions_out: bool = False, only_expansions: bool = False, session: Session = Depends(get_session)):