Skip to content
Snippets Groups Projects
Commit 891eacb0 authored by robban64's avatar robban64
Browse files

fix: lazy

parent b102b788
No related branches found
No related tags found
1 merge request!73Resolve "Fix api response"
Pipeline #41333 passed with warnings
......@@ -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"
}
......
......@@ -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))
......
......@@ -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)
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment