Set scores
This commit is contained in:
@@ -1,11 +1,9 @@
|
||||
from collections.abc import Iterable, Iterator
|
||||
from collections.abc import Iterable
|
||||
|
||||
from fastapi import HTTPException
|
||||
from folkugat_web.dal.sql.temes import scores as scores_dal
|
||||
from folkugat_web.model import playlists as playlists_model
|
||||
from folkugat_web.model import temes as model
|
||||
from folkugat_web.model.lilypond import score as lilypond_model
|
||||
from folkugat_web.services import lilypond
|
||||
from folkugat_web.services.temes import lyrics as lyrics_service
|
||||
from folkugat_web.services.temes import properties as properties_service
|
||||
from folkugat_web.services.temes import query as temes_q
|
||||
@@ -82,17 +80,15 @@ def build_set_title(temes: list[model.Tema | None]) -> str:
|
||||
|
||||
|
||||
def set_from_set(set_entry: playlists_model.Set) -> lilypond_model.LilypondSet:
|
||||
def _build_temes_by_id(temes: Iterable[model.Tema]) -> dict[int, model.Tema]:
|
||||
return {tema.id: tema for tema in temes if tema.id is not None}
|
||||
"""
|
||||
The tune_set is assumed to be enriched with tunes
|
||||
"""
|
||||
tema_ids = [tema_in_set.tema_id for tema_in_set in set_entry.temes]
|
||||
temes_by_id = (
|
||||
FnChain.transform([tema_id for tema_id in tema_ids if tema_id is not None]) |
|
||||
temes_q.get_temes_by_ids |
|
||||
properties_service.add_properties_to_temes |
|
||||
lyrics_service.add_lyrics_to_temes |
|
||||
scores_service.add_scores_to_temes |
|
||||
_build_temes_by_id
|
||||
).result()
|
||||
temes_by_id = {
|
||||
tema_in_set.tema_id: tema_in_set.tema
|
||||
for tema_in_set in set_entry.temes
|
||||
if tema_in_set.id is not None and tema_in_set.tema
|
||||
}
|
||||
temes = [temes_by_id[tema_id] if tema_id is not None else None for tema_id in tema_ids]
|
||||
set_title = build_set_title(temes=temes)
|
||||
tunes = tunes_from_temes(temes)
|
||||
|
||||
Reference in New Issue
Block a user