From 7d7bf134250f614015a159d684c4dd8684571bbf Mon Sep 17 00:00:00 2001 From: David Trattnig <david.trattnig@o94.at> Date: Mon, 23 Nov 2020 15:21:46 +0100 Subject: [PATCH] Skip ended timeslot. engine-clock#2 --- src/service.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/service.py b/src/service.py index a6163dd..5e57f4f 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) -- GitLab