backend.services.setlist
Setlist service.
Provides SetlistService which encapsulates all business logic
for loading a gig with its full set/song structure and calculating the
expected start time for each song based on the gig start time, song
durations and set-break durations.
- class backend.services.setlist.SetlistService(session)[Quellcode]
Bases:
objectBusiness-logic service for setlist operations.
- Parameter:
session (Session) – An active SQLAlchemy database session.
- DEFAULT_BREAK = 35
- load_gig(gig_id)[Quellcode]
Load a
Gigwith all related sets and songs eagerly loaded in a single query.
- calc_schedule(gig)[Quellcode]
Calculate the expected start time for every song in every set of the gig.
The calculation walks the sets in their
GigSet.positionorder, accumulates song durations (defaulting to 4 minutes when unknown) plus a short inter-song gap ofDEFAULT_BREAKseconds, and then adds the full set-break duration between sets.- Parameter:
gig (Gig) – A fully-loaded gig object (use
load_gig()).- Rückgabe:
A mapping of
{set_position: [song_start_datetime, ...]}.- Rückgabetyp:
- dump_gig_struct(gig, schedule=None)[Quellcode]
Print a human-readable, Markdown-style overview of the gig structure including live-mode annotations to stdout.
- Parameter:
gig – A fully-loaded gig object.
schedule (dict | None) – Optional schedule dict as returned by
calc_schedule(). If supplied, song start times are printed next to each song.