diff --git a/codeGrader/backend/api/app.py b/codeGrader/backend/api/app.py index 4233d55..9b4d9a9 100644 --- a/codeGrader/backend/api/app.py +++ b/codeGrader/backend/api/app.py @@ -537,6 +537,7 @@ def addSubmission() -> dict: @app.route("/submission/", methods=["GET"]) +@cache.memoize(config.cache_timeout, unless=cache_bypass) @authentication def submission(id_) -> dict: """ @@ -551,6 +552,7 @@ def submission(id_) -> dict: @app.route("/submissions", methods=['GET']) +@cache.cached(config.cache_timeout, unless=cache_bypass, query_string=True) @authentication def submissions() -> dict: """ @@ -594,6 +596,7 @@ def testcase(id_) -> dict: @app.route("/testcases", methods=['GET']) +@cache.cached(config.cache_timeout, unless=cache_bypass, query_string=True) @authentication def testcases() -> dict: """ diff --git a/codeGrader/backend/db/Exercise.py b/codeGrader/backend/db/Exercise.py index be449d3..8dc28be 100644 --- a/codeGrader/backend/db/Exercise.py +++ b/codeGrader/backend/db/Exercise.py @@ -78,7 +78,7 @@ class Exercise(Base): passive_deletes=True, lazy="subquery", join_depth=3, - backref=backref("TaskExercise", lazy="joined", join_depth=3) + backref=backref("TaskExercise", lazy="subquery", join_depth=3) ) def get_profile(self): diff --git a/codeGrader/backend/db/Subject.py b/codeGrader/backend/db/Subject.py index 35dd302..9ecb0e4 100644 --- a/codeGrader/backend/db/Subject.py +++ b/codeGrader/backend/db/Subject.py @@ -72,7 +72,8 @@ class Subject(Base): cascade="all", passive_deletes=True, lazy="subquery", - backref=backref("ExerciseSubject", lazy="joined") + join_depth=1, + backref=backref("ExerciseSubject", lazy="joined", join_depth=1) ) memberships = relationship( @@ -83,7 +84,7 @@ class Subject(Base): cascade="all", passive_deletes=True, lazy="noload", - backref=backref("MembershipSubject", lazy="joined", join_depth=3) + backref=backref("MembershipSubject", lazy="joined", join_depth=2) ) def get_profile(self) -> dict: diff --git a/codeGrader/backend/db/Task.py b/codeGrader/backend/db/Task.py index b38bd11..1f986d9 100644 --- a/codeGrader/backend/db/Task.py +++ b/codeGrader/backend/db/Task.py @@ -108,7 +108,7 @@ class Task(Base): cascade="all", passive_deletes=True, lazy="subquery", - backref=backref("TaskTestCase", lazy="subquery") + backref=backref("TaskTestCase", lazy="noload") ) def get_profile(self) -> dict: diff --git a/codeGrader/backend/db/TestCase.py b/codeGrader/backend/db/TestCase.py index 4e8d627..2622027 100644 --- a/codeGrader/backend/db/TestCase.py +++ b/codeGrader/backend/db/TestCase.py @@ -104,8 +104,8 @@ def toJson(self, recursive: bool = True) -> dict: out = dict() out["id"] = self.id - out["task"] = self.TaskTestCase.toJson() - out["task_id"] = out["task"]["id"] + #out["task"] = self.TaskTestCase.toJson() + out["task_id"] = self.task_id out["input_file"] = self.input_file.toJson(include_binary=False) out["input_file_id"] = self.input_file.id out["output_file"] = self.output_file.toJson(include_binary=False) diff --git a/codeGrader/frontend/admin/templates/task.html b/codeGrader/frontend/admin/templates/task.html index 8869ace..1969513 100644 --- a/codeGrader/frontend/admin/templates/task.html +++ b/codeGrader/frontend/admin/templates/task.html @@ -451,7 +451,7 @@

- {% for sub in submissions | sort(attribute='id') %} + {% for sub in submissions | sort(reverse=true, attribute='id') %} {{ sub["id"] }}