diff --git a/libraries/database/broadcasts.py b/libraries/database/broadcasts.py index 4795c87d31e60bccf94c990f570060e8e4f779b9..e895ee699f26379e29a72671e0c2782d23707538 100644 --- a/libraries/database/broadcasts.py +++ b/libraries/database/broadcasts.py @@ -43,8 +43,11 @@ from libraries.base.config import AuraConfig from modules.base.simpleutil import SimpleUtil +# Init Config +config = AuraConfig() + # Initialize DB Model and session -engine = sa.create_engine(AuraConfig().get_database_uri()) +engine = sa.create_engine(config.get_database_uri()) Base = declarative_base() Base.metadata.bind = engine @@ -555,6 +558,27 @@ class TrackService(DB.Model, AuraDatabaseModel): return None + @hybrid_property + def show(self): + """ + Retrieves show information based on the related schedule. If no schedule + is available (e.g. when the engine is in a fallback state), then the default + show properties from `AuraConfig` are returned. + """ + show_info = {} + + if self.schedule: + show_info["name"] = self.schedule.show_name + show_info["type"] = self.schedule.type + show_info["host"] = self.show_hosts.show_name + elif self.fallback_type == 4: + show_info["name"] = config.get("fallback_show_name") + show_info["type"] = config.get("fallback_show_type") + show_info["host"] = config.get("fallback_show_host") + + return show_info + + @staticmethod def select_one(id): """