xing things.

Signed-off-by: Cliff Hill <xlorep@darkhelm.org>
This commit is contained in:
2024-04-23 13:33:49 -04:00
parent 7af96ca7b9
commit 8f882659c2
3 changed files with 198 additions and 24 deletions
+35
View File
@@ -244,10 +244,19 @@ async def update_statistics(
new_average_duration: float,
new_podcast_length: float,
new_max_playtime: float,
new_category_count: int,
new_active_holidays: int,
new_max_tracks: int,
new_max_regular: int,
new_max_holiday: int,
new_max_regular_favorite: int,
new_max_regular_general: int,
new_max_holiday_favorite: int,
new_max_holiday_general: int,
new_max_regular_favorite_base: int,
new_max_regular_general_base: int,
new_max_holiday_favorite_base: int,
new_max_holiday_general_base: int,
) -> None:
"""Update the statistics model.
@@ -256,10 +265,19 @@ async def update_statistics(
of all track durations as a float.
new_podcast_length (float): The new total podcast length of all current episodes as a float.
new_max_playtime (float): The new max playtime as a float.
new_category_count (int): The new count of categories as an int.
new_active_holidays (int): The new active holidays as an int.
new_max_tracks (int): The new max tracks per day as an int.
new_max_regular (int): The new max regular tracks as an int.
new_max_holiday (int): The new max holiday tracks as an int.
new_max_regular_favorite (int): The new max regular favorite tracks as an int.
new_max_regular_general (int): The new max regular general tracks as an int.
new_max_holiday_favorite (int): The new max holiday favorite tracks as an int.
new_max_holiday_general (int): The new max holiday general tracks as an int.
new_max_regular_favorite_base (int): The new max regular favorite base unit as an int.
new_max_regular_general_base (int): The new max regular general base unit as an int.
new_max_holiday_favorite_base (int): The new max holiday favorite base unit as an int.
new_max_holiday_general_base (int): The new max holiday general base unit as an int.
"""
async with async_session_maker() as session:
try:
@@ -272,10 +290,19 @@ async def update_statistics(
stats.average_track_length = new_average_duration
stats.total_podcast_length = new_podcast_length
stats.max_playtime = new_max_playtime
stats.category_count = new_category_count
stats.active_holiday_count = new_active_holidays
stats.max_tracks_per_day = new_max_tracks
stats.max_regular_tracks = new_max_regular
stats.max_holiday_tracks = new_max_holiday
stats.max_regular_favorite_tracks = new_max_regular_favorite
stats.max_regular_general_tracks = new_max_regular_general
stats.max_holiday_favorite_tracks = new_max_holiday_favorite
stats.max_holiday_general_tracks = new_max_holiday_general
stats.max_regular_favorite_base = new_max_regular_favorite_base
stats.max_regular_general_base = new_max_regular_general_base
stats.max_holiday_favorite_base = new_max_holiday_favorite_base
stats.max_holiday_general_base = new_max_holiday_general_base
await session.commit()
else:
# If no statistics entry exists, create one
@@ -287,6 +314,14 @@ async def update_statistics(
max_tracks_per_day=new_max_tracks,
max_regular_tracks=new_max_regular,
max_holiday_tracks=new_max_holiday,
max_regular_favorite_tracks=new_max_regular_favorite,
max_regular_general_tracks=new_max_regular_general,
max_holiday_favorite_tracks=new_max_holiday_favorite,
max_holiday_general_tracks=new_max_holiday_general,
max_regular_favorite_base=new_max_regular_favorite_base,
max_regular_general_base=new_max_regular_general_base,
max_holiday_favorite_base=new_max_holiday_favorite_base,
max_holiday_general_base=new_max_holiday_general_base,
)
session.add(new_stats)
await session.commit()