diff options
author | Jesse Antti Matikainen <jmatikai@local> | 2023-12-03 14:48:30 +0200 |
---|---|---|
committer | Jesse Antti Matikainen <jmatikai@local> | 2023-12-03 14:48:30 +0200 |
commit | 477410a6c033a0cbd8b07fae123a1e9386488ba6 (patch) | |
tree | 46aa681a09bcff93d1d04566163af7bd2bb8a7a7 /db/analyse.py | |
parent | b538d8236cd9cf92c36df47ddf244096896f5068 (diff) |
Implementing user combination gathering in SQL.
Diffstat (limited to 'db/analyse.py')
-rw-r--r-- | db/analyse.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/db/analyse.py b/db/analyse.py index 612f637..c958cc1 100644 --- a/db/analyse.py +++ b/db/analyse.py @@ -38,3 +38,15 @@ class DBAnalyse: } ).scalar() + def combinations(self, quiz_id): + sql = "SELECT u1.id, u2.id \ + FROM questionaires quiz \ + JOIN answers a1 ON a1.question_id = quiz.questionset[1] \ + JOIN answers a2 ON a2.question_id = quiz.questionset[1] \ + JOIN users u1 ON u1.id = a1.user_id \ + JOIN users u2 ON u2.id = a2.user_id \ + WHERE quiz.id = (:quiz_id) AND u1.id > u2.id;" + return self.db.session.execute( text(sql), { + 'quiz_id': quiz_id + } ).fetchall() + |