Various fixes
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import datetime
|
||||
from typing import Annotated, Optional
|
||||
from typing import Annotated
|
||||
|
||||
import jwt
|
||||
from fastapi import Cookie, Depends, HTTPException
|
||||
|
||||
@@ -4,6 +4,7 @@ from folkugat_web.dal.sql.playlists import query, write
|
||||
from folkugat_web.log import logger
|
||||
from folkugat_web.model import playlists
|
||||
from folkugat_web.services.temes import links as links_service
|
||||
from folkugat_web.services.temes import lyrics as lyrics_service
|
||||
from folkugat_web.services.temes import query as temes_query
|
||||
from folkugat_web.services.temes import scores as scores_service
|
||||
|
||||
@@ -27,6 +28,7 @@ def add_tema_to_tema_in_set(tema_in_set: playlists.TemaInSet) -> playlists.TemaI
|
||||
logger.error("fCould not load tune in set: {tema_in_set}")
|
||||
else:
|
||||
_ = links_service.add_links_to_tema(tema_in_set.tema)
|
||||
_ = lyrics_service.add_lyrics_to_tema(tema_in_set.tema)
|
||||
_ = scores_service.add_scores_to_tema(tema_in_set.tema)
|
||||
return tema_in_set
|
||||
|
||||
|
||||
@@ -16,9 +16,10 @@ def tema_compute_stats(
|
||||
if tune_sessions_dict is None:
|
||||
tune_sessions_dict = playlists_q.get_tune_sessions(tema_ids=[tema.id])
|
||||
if tema.id and (tune_sessions := tune_sessions_dict.get(tema.id)):
|
||||
unique_tune_sessions = set(tune_sessions)
|
||||
tema.stats = model.Stats(
|
||||
times_played=len(tune_sessions),
|
||||
sessions_played=list(reversed(sorted(tune_sessions, key=lambda s: s.date))),
|
||||
times_played=len(unique_tune_sessions),
|
||||
sessions_played=list(reversed(sorted(unique_tune_sessions, key=lambda s: s.date))),
|
||||
)
|
||||
return tema
|
||||
|
||||
|
||||
Reference in New Issue
Block a user