Do not render set score for single tune

This commit is contained in:
marc
2025-04-26 22:38:43 +02:00
parent e6b8b3e809
commit e07ec0b9bf
2 changed files with 14 additions and 1110 deletions

View File

@@ -100,9 +100,20 @@ def _elegible_for_set_score(tune: lilypond_model.LilypondTune) -> bool:
async def get_or_create_set_score(tune_set: playlists.Set) -> playlists.SetScore | None:
# The tune_set is assumed to be enriched with tunes
lilypond_set = lilypond_build.set_from_set(set_entry=tune_set)
if not all(map(_elegible_for_set_score, lilypond_set.tunes)):
if not tune_set.temes:
return None
if len(tune_set.temes) == 1:
if (tema := tune_set.temes[0].tema) is None or (main_score := tema.main_score()) is None:
return None
return playlists.SetScore(
pdf_url=main_score.pdf_url,
img_url=main_score.img_url,
)
lilypond_set = lilypond_build.set_from_set(set_entry=tune_set)
if not lilypond_set.tunes or not all(map(_elegible_for_set_score, lilypond_set.tunes)):
return None
set_score_hash = lilypond_set.hash().hex()
pdf_filepath = files_service.get_set_filename(f"{set_score_hash}.pdf")