From a343c91c1f1779136e638b918d4ca1719e2728ed Mon Sep 17 00:00:00 2001
From: David Trattnig <david.trattnig@o94.at>
Date: Mon, 9 Mar 2020 16:01:11 +0100
Subject: [PATCH] Fallback show info.

---
 libraries/database/broadcasts.py | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/libraries/database/broadcasts.py b/libraries/database/broadcasts.py
index 4795c87d..e895ee69 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):
         """
-- 
GitLab