Commit 3ad40d80 authored by David Trattnig's avatar David Trattnig
Browse files

Initial fixes for playlist scheduling.

parent 88aa9433
......@@ -30,8 +30,9 @@ import datetime
from sqlalchemy import orm, func, BigInteger, Boolean, Column, DateTime, Integer, String, ForeignKey, ForeignKeyConstraint
from sqlalchemy.orm import relationship
from sqlalchemy.sql.expression import false, true
from sqlalchemy.ext.hybrid import hybrid_property, hybrid_method
from sqlalchemy.orm import relationship
from sqlalchemy import create_engine
from libraries.enum.auraenumerations import ScheduleEntryType
......@@ -230,7 +231,7 @@ class Playlist(DB.Model, AuraDatabaseModel):
playlist_id = Column(Integer, autoincrement=False) # , ForeignKey("schedule.playlist_id"))
show_name = Column(String(256))
fallback_type = Column(Integer)
entry_count = Column(Integer)
entry_count = Column(Integer)
@staticmethod
def select_all():
......@@ -248,6 +249,14 @@ class Playlist(DB.Model, AuraDatabaseModel):
def select_playlist_for_schedule(datetime, playlist_id):
return DB.session.query(Playlist).filter(Playlist.schedule_start == datetime, Playlist.playlist_id == playlist_id).first()
@staticmethod
def select_playlist(playlist_id):
return DB.session.query(Playlist).filter(Playlist.playlist_id == playlist_id).order_by(Playlist.schedule_start).all()
@hybrid_property
def start_unix(self):
return time.mktime(self.schedule_start.timetuple())
# ------------------------------------------------------------------------------------------ #
class PlaylistEntry(DB.Model, AuraDatabaseModel):
......@@ -272,7 +281,11 @@ class PlaylistEntry(DB.Model, AuraDatabaseModel):
def select_playlistentry_for_playlist(artificial_playlist_id, entry_num):
return DB.session.query(PlaylistEntry).filter(PlaylistEntry.artificial_playlist_id == artificial_playlist_id, PlaylistEntry.entry_num == entry_num).first()
@hybrid_property
def start_unix(self):
return time.mktime(self.entry_start.timetuple())
# ------------------------------------------------------------------------------------------ #
class PlaylistEntryMetaData(DB.Model, AuraDatabaseModel):
__tablename__ = "playlist_entry_metadata"
......
......@@ -170,7 +170,8 @@ class CalendarFetcher:
# if a playlist is already fetched, do not fetch it again
for entry in fetched_schedule_entries:
if entry["playlist_id"] == schedule[id_name]:
# FIXME schedule["playlist_id"] is always None, review if entry["id"] is valid
if entry["id"] == schedule[id_name]:
self.logger.debug("playlist #" + str(schedule[id_name]) + " already fetched")
return entry
......
......@@ -258,7 +258,7 @@ class AuraScheduler(ExceptionLogger, threading.Thread):
self.logger.critical("ENABLING FADEOUTTIMER FOR " + str(old_entry))
# same for fadein except old_entry can be None
if old_entry.type != new_entry.type:
else:
#self.add_or_update_timer(diff, self.liquidsoapcommunicator.fade_in, [new_entry])
new_entry.fadeintimer = self.create_timer(diff, self.liquidsoapcommunicator.fade_in, [new_entry], fadein=True)
self.logger.critical("ENABLING FADEINTIMER FOR " + str(new_entry))
......@@ -267,7 +267,7 @@ class AuraScheduler(ExceptionLogger, threading.Thread):
def add_or_update_timer(self, diff, func, parameters):
timer = None
entry = parameters[0]
planned_timer = self.is_something_planned_at_time(entry.entry_start)
planned_timer = self.is_something_planned_at_time(entry.schedule_start)
# if something is planned on entry.entry_start
if planned_timer:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment