Added expansion filtering to games_over_time
This commit is contained in:
parent
f21d63d23e
commit
e976d2e83e
1 changed files with 10 additions and 2 deletions
12
src/main.py
12
src/main.py
|
|
@ -86,7 +86,7 @@ def get_amount_of_games():
|
|||
return statistic_to_return
|
||||
|
||||
@app.get('/statistics/amount_of_games_over_time', response_model=statistic_classes.TimeLineStatistic)
|
||||
def get_amount_of_games_over_time(day_step: int = 1):
|
||||
def get_amount_of_games_over_time(day_step: int = 1, filter_expansions_out: bool = False, only_expansions: bool = False):
|
||||
|
||||
def daterange(start_date: date, end_date: date, day_step):
|
||||
days = int((end_date - start_date).days)
|
||||
|
|
@ -96,9 +96,17 @@ def get_amount_of_games_over_time(day_step: int = 1):
|
|||
games_in_owned_collection = data_connection.get_user_owned_collection()
|
||||
games_in_owned_collection.sort(key=lambda x: x.acquisition_date)
|
||||
|
||||
start_date = games_in_owned_collection[0].acquisition_date
|
||||
|
||||
if filter_expansions_out:
|
||||
games_in_owned_collection = boardgame_filters.filter_expansions_out(games_in_owned_collection)
|
||||
|
||||
if only_expansions:
|
||||
games_in_owned_collection = boardgame_filters.filter_non_expansions_out(games_in_owned_collection)
|
||||
|
||||
timeline_dict = {}
|
||||
|
||||
for current_date in daterange(games_in_owned_collection[0].acquisition_date, date.today(), day_step):
|
||||
for current_date in daterange(start_date, date.today(), day_step):
|
||||
games_in_collection_at_date = list(filter(lambda game: game.acquisition_date <= current_date, games_in_owned_collection))
|
||||
timeline_dict[current_date] = len(games_in_collection_at_date)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue