From b1afdf3cab785c9194dea3395aa4751cca9a5a4d Mon Sep 17 00:00:00 2001 From: Michael Kaiser Date: Sun, 19 May 2024 18:49:20 +0200 Subject: [PATCH 1/5] performance improvment on loading testcases --- codeGrader/backend/db/Task.py | 2 +- codeGrader/backend/db/TestCase.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) 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) From c6aae7d30ed5d60a0f79110d40c26993e6cd3345 Mon Sep 17 00:00:00 2001 From: Michael Kaiser Date: Sun, 19 May 2024 18:52:15 +0200 Subject: [PATCH 2/5] fixed wrong order of submissions for tasks in admin panel --- codeGrader/frontend/admin/templates/task.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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"] }} From 813bf84bf32944f19bd8d0069f0ff45749497c70 Mon Sep 17 00:00:00 2001 From: Michael Kaiser Date: Sun, 19 May 2024 19:00:59 +0200 Subject: [PATCH 3/5] adding cahcing to testcases route in backend api --- codeGrader/backend/api/app.py | 1 + 1 file changed, 1 insertion(+) diff --git a/codeGrader/backend/api/app.py b/codeGrader/backend/api/app.py index 4233d55..615613d 100644 --- a/codeGrader/backend/api/app.py +++ b/codeGrader/backend/api/app.py @@ -594,6 +594,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: """ From d53932cde812ce02768f918a9aba5e8efa7cc1c7 Mon Sep 17 00:00:00 2001 From: Michael Kaiser Date: Sun, 19 May 2024 19:03:19 +0200 Subject: [PATCH 4/5] adding cache to submissions and submission route in backend api --- codeGrader/backend/api/app.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/codeGrader/backend/api/app.py b/codeGrader/backend/api/app.py index 615613d..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: """ From 2710b140e7e0cd942cfbadd805cd954987201011 Mon Sep 17 00:00:00 2001 From: Michael Kaiser Date: Thu, 23 May 2024 16:18:34 +0200 Subject: [PATCH 5/5] performance tuning of the database access for much faster api calls --- codeGrader/backend/db/Exercise.py | 2 +- codeGrader/backend/db/Subject.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) 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: