From db6777276d989581d508fb156bde2cc7399b6659 Mon Sep 17 00:00:00 2001 From: pasha1coil Date: Sun, 24 Aug 2025 09:46:09 +0300 Subject: [PATCH] added in QuestionsStatistics some !=start --- dal/db_query/queries.sql | 7 ++++--- dal/sqlcgen/queries.sql.go | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/dal/db_query/queries.sql b/dal/db_query/queries.sql index a1b082b..510f06d 100644 --- a/dal/db_query/queries.sql +++ b/dal/db_query/queries.sql @@ -513,7 +513,7 @@ FROM -- name: QuestionsStatistics :many WITH QuizAnswers AS ( -SELECT +SELECT session, start, result, question_id, created_at, content, quiz_id FROM answer WHERE answer.quiz_id = $1 AND created_at between TO_TIMESTAMP($2)::timestamp and TO_TIMESTAMP($3)::timestamp @@ -545,6 +545,7 @@ SELECT AND a.created_at >= TO_TIMESTAMP($2) AND a.created_at <= TO_TIMESTAMP($3) AND a.result = TRUE + AND a.start = FALSE GROUP BY q.title, a.quiz_id, a.result HAVING @@ -567,7 +568,7 @@ SELECT QuizAnswers WHERE quiz_id = $1 - AND start != true + AND start = FALSE AND created_at >= TO_TIMESTAMP($2) AND created_at <= TO_TIMESTAMP($3) GROUP BY @@ -588,7 +589,7 @@ SELECT JOIN answer a ON q.id = a.question_id WHERE a.quiz_id = $1 - AND a.start != true + AND a.start = FALSE AND a.created_at >= TO_TIMESTAMP($2) AND a.created_at <= TO_TIMESTAMP($3) GROUP BY diff --git a/dal/sqlcgen/queries.sql.go b/dal/sqlcgen/queries.sql.go index 544eeb2..fcb288a 100644 --- a/dal/sqlcgen/queries.sql.go +++ b/dal/sqlcgen/queries.sql.go @@ -4773,7 +4773,7 @@ func (q *Queries) MoveToHistoryQuiz(ctx context.Context, arg MoveToHistoryQuizPa const questionsStatistics = `-- name: QuestionsStatistics :many WITH QuizAnswers AS ( -SELECT +SELECT session, start, result, question_id, created_at, content, quiz_id FROM answer WHERE answer.quiz_id = $1 AND created_at between TO_TIMESTAMP($2)::timestamp and TO_TIMESTAMP($3)::timestamp @@ -4805,6 +4805,7 @@ SELECT AND a.created_at >= TO_TIMESTAMP($2) AND a.created_at <= TO_TIMESTAMP($3) AND a.result = TRUE + AND a.start = FALSE GROUP BY q.title, a.quiz_id, a.result HAVING @@ -4827,7 +4828,7 @@ SELECT QuizAnswers WHERE quiz_id = $1 - AND start != true + AND start = FALSE AND created_at >= TO_TIMESTAMP($2) AND created_at <= TO_TIMESTAMP($3) GROUP BY @@ -4848,7 +4849,7 @@ SELECT JOIN answer a ON q.id = a.question_id WHERE a.quiz_id = $1 - AND a.start != true + AND a.start = FALSE AND a.created_at >= TO_TIMESTAMP($2) AND a.created_at <= TO_TIMESTAMP($3) GROUP BY