From 891eacb0488de16a1f761f429fbb44d0ae813357 Mon Sep 17 00:00:00 2001
From: robban64 <carl@schonfelder.se>
Date: Tue, 20 Apr 2021 11:51:33 +0200
Subject: [PATCH] fix: lazy

---
 client/package-lock.json              | 3 ++-
 server/app/apis/competitions.py       | 2 +-
 server/app/database/controller/get.py | 7 +++++--
 server/configmodule.py                | 1 +
 4 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/client/package-lock.json b/client/package-lock.json
index 1ac23cb5..667b7585 100644
--- a/client/package-lock.json
+++ b/client/package-lock.json
@@ -17239,7 +17239,8 @@
         },
         "ssri": {
           "version": "6.0.1",
-          "resolved": "",
+          "resolved": "https://registry.npmjs.org/ssri/-/ssri-6.0.1.tgz",
+          "integrity": "sha512-3Wge10hNcT1Kur4PDFwEieXSCMCJs/7WvSACcrMYrNp+b8kDL1/0wJch5Ni2WrtwEa2IO8OsVfeKIciKCDx/QA==",
           "requires": {
             "figgy-pudding": "^3.5.1"
           }
diff --git a/server/app/apis/competitions.py b/server/app/apis/competitions.py
index d81a3daf..db2ca68a 100644
--- a/server/app/apis/competitions.py
+++ b/server/app/apis/competitions.py
@@ -34,7 +34,7 @@ class CompetitionsList(Resource):
 class Competitions(Resource):
     @check_jwt(editor=True)
     def get(self, CID):
-        item = dbc.get.one(Competition, CID)
+        item = dbc.get.competition(CID)
 
         return item_response(rich_schema.dump(item))
 
diff --git a/server/app/database/controller/get.py b/server/app/database/controller/get.py
index 98aa8229..f7d14914 100644
--- a/server/app/database/controller/get.py
+++ b/server/app/database/controller/get.py
@@ -23,13 +23,13 @@ from sqlalchemy.orm import contains_eager, joinedload, subqueryload
 
 
 def all(db_type):
-    """ Gets all elements in the provided table. """
+    """ Gets lazy db-item in the provided table. """
 
     return db_type.query.all()
 
 
 def one(db_type, id, required=True, error_msg=None):
-    """ Gets the element in the table that has the same id. """
+    """ Get lazy db-item in the table that has the same id. """
 
     return db_type.query.filter(db_type.id == id).first_extended(required, error_msg)
 
@@ -79,6 +79,9 @@ def question(CID, SOrder, QID, required=True, error_msg=None):
 
 
 def competition(CID):
+    """ Get Competition and all it's sub-entities """
+    """ HOT PATH """
+
     os1 = joinedload(Competition.slides).joinedload(Slide.components)
     os2 = joinedload(Competition.slides).joinedload(Slide.questions).joinedload(Question.alternatives)
     ot = joinedload(Competition.teams).joinedload(Team.question_answers)
diff --git a/server/configmodule.py b/server/configmodule.py
index 1c80dc80..78537a0e 100644
--- a/server/configmodule.py
+++ b/server/configmodule.py
@@ -26,6 +26,7 @@ class DevelopmentConfig(Config):
     # USER = "postgres"
     # PASSWORD = "password"
     # DATABASE = "teknik8"
+    # SQLALCHEMY_DATABASE_URI = "sqlite:///database.db"
     # SQLALCHEMY_DATABASE_URI = "postgresql://" + USER + ":" + PASSWORD + "@" + HOST + ":" + str(PORT) + "/" + DATABASE
     SQLALCHEMY_ECHO = False
 
-- 
GitLab