diff --git a/src/service.py b/src/service.py index a6163ddba49e14caf694e5df7ee526453c9d7ba2..5e57f4ff41c4fc6eb2f8a477bc04470e257a5106 100644 --- a/src/service.py +++ b/src/service.py @@ -25,6 +25,7 @@ import sqlalchemy from dateutil.parser import parse from base.node import NodeType +from rest import util from models import \ PlayLog, PlayLogSchema, TrackSchema, ActivityLog, \ ClockInfo, ClockInfoSchema, HealthHistory, HealthHistorySchema @@ -188,7 +189,14 @@ class ApiService(): """ Retrieves the dataset required to render the studio clock. """ - info = ClockInfo.get_info(self.get_active_source()) + info = ClockInfo.get_info(self.get_active_source()) + + now = datetime.datetime.now() + if info["current_timeslot"] and info["current_timeslot"]["timeslot_end"]: + timeslot_end = util.deserialize_datetime(info["current_timeslot"]["timeslot_end"]) + if timeslot_end < now: + info["current_timeslot"] = None + clockinfo_schema = ClockInfoSchema() return clockinfo_schema.dump(info)