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: object

Business-logic service for setlist operations.

Parameter:

session (Session) – An active SQLAlchemy database session.

DEFAULT_BREAK = 35
load_gig(gig_id)[Quellcode]

Load a Gig with all related sets and songs eagerly loaded in a single query.

Parameter:

gig_id (int) – Primary key of the gig to load.

Rückgabe:

The gig object with all relationships populated, or None if not found.

Rückgabetyp:

Gig | None

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.position order, accumulates song durations (defaulting to 4 minutes when unknown) plus a short inter-song gap of DEFAULT_BREAK seconds, 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:

dict[int, list[datetime]]

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.