update sqlc gen
This commit is contained in:
parent
cd4fd47196
commit
469ccf80e2
@ -535,31 +535,37 @@ WITH Funnel AS (
|
|||||||
COUNT(*) >= 1
|
COUNT(*) >= 1
|
||||||
),
|
),
|
||||||
Questions AS (
|
Questions AS (
|
||||||
SELECT
|
SELECT
|
||||||
q.id,
|
q.title AS question_title,
|
||||||
q.title AS question_title,
|
NULL AS answer_content,
|
||||||
a.content AS answer_content,
|
CAST(COUNT(*) * 100.0 / NULLIF(q.total_answers, 0) AS INTEGER) AS percentage
|
||||||
CAST(COUNT(*) * 100.0 / NULLIF(q.total_answers, 0) AS INTEGER) AS percentage
|
FROM
|
||||||
FROM
|
answer a
|
||||||
answer a
|
JOIN (
|
||||||
JOIN (
|
SELECT
|
||||||
SELECT q.id, q.title, COUNT(*) AS total_answers
|
q.id,
|
||||||
FROM question q
|
q.title,
|
||||||
JOIN answer a ON q.id = a.question_id
|
COUNT(*) AS total_answers
|
||||||
WHERE a.quiz_id = $1
|
FROM
|
||||||
AND a.created_at >= TO_TIMESTAMP($2)
|
question q
|
||||||
AND a.created_at <= TO_TIMESTAMP($3)
|
JOIN
|
||||||
GROUP BY q.id, q.title
|
answer a ON q.id = a.question_id
|
||||||
) q ON a.question_id = q.id
|
WHERE
|
||||||
WHERE
|
a.quiz_id = $1
|
||||||
a.quiz_id = $1
|
AND a.created_at >= TO_TIMESTAMP($2)
|
||||||
AND a.created_at >= TO_TIMESTAMP($2)
|
AND a.created_at <= TO_TIMESTAMP($3)
|
||||||
AND a.created_at <= TO_TIMESTAMP($3)
|
GROUP BY
|
||||||
GROUP BY
|
q.id, q.title
|
||||||
q.id, q.title, a.content, q.total_answers
|
) q ON a.question_id = q.id
|
||||||
HAVING
|
WHERE
|
||||||
COUNT(*) >= 1
|
a.quiz_id = $1
|
||||||
)
|
AND a.created_at >= TO_TIMESTAMP($2)
|
||||||
|
AND a.created_at <= TO_TIMESTAMP($3)
|
||||||
|
GROUP BY
|
||||||
|
q.title, q.total_answers
|
||||||
|
HAVING
|
||||||
|
COUNT(*) >= 1
|
||||||
|
)
|
||||||
SELECT
|
SELECT
|
||||||
Funnel.count_start_false,
|
Funnel.count_start_false,
|
||||||
Funnel.count_start_true,
|
Funnel.count_start_true,
|
||||||
|
@ -1629,31 +1629,37 @@ WITH Funnel AS (
|
|||||||
COUNT(*) >= 1
|
COUNT(*) >= 1
|
||||||
),
|
),
|
||||||
Questions AS (
|
Questions AS (
|
||||||
SELECT
|
SELECT
|
||||||
q.id,
|
q.title AS question_title,
|
||||||
q.title AS question_title,
|
NULL AS answer_content,
|
||||||
a.content AS answer_content,
|
CAST(COUNT(*) * 100.0 / NULLIF(q.total_answers, 0) AS INTEGER) AS percentage
|
||||||
CAST(COUNT(*) * 100.0 / NULLIF(q.total_answers, 0) AS INTEGER) AS percentage
|
FROM
|
||||||
FROM
|
answer a
|
||||||
answer a
|
JOIN (
|
||||||
JOIN (
|
SELECT
|
||||||
SELECT q.id, q.title, COUNT(*) AS total_answers
|
q.id,
|
||||||
FROM question q
|
q.title,
|
||||||
JOIN answer a ON q.id = a.question_id
|
COUNT(*) AS total_answers
|
||||||
WHERE a.quiz_id = $1
|
FROM
|
||||||
AND a.created_at >= TO_TIMESTAMP($2)
|
question q
|
||||||
AND a.created_at <= TO_TIMESTAMP($3)
|
JOIN
|
||||||
GROUP BY q.id, q.title
|
answer a ON q.id = a.question_id
|
||||||
) q ON a.question_id = q.id
|
WHERE
|
||||||
WHERE
|
a.quiz_id = $1
|
||||||
a.quiz_id = $1
|
AND a.created_at >= TO_TIMESTAMP($2)
|
||||||
AND a.created_at >= TO_TIMESTAMP($2)
|
AND a.created_at <= TO_TIMESTAMP($3)
|
||||||
AND a.created_at <= TO_TIMESTAMP($3)
|
GROUP BY
|
||||||
GROUP BY
|
q.id, q.title
|
||||||
q.id, q.title, a.content, q.total_answers
|
) q ON a.question_id = q.id
|
||||||
HAVING
|
WHERE
|
||||||
COUNT(*) >= 1
|
a.quiz_id = $1
|
||||||
)
|
AND a.created_at >= TO_TIMESTAMP($2)
|
||||||
|
AND a.created_at <= TO_TIMESTAMP($3)
|
||||||
|
GROUP BY
|
||||||
|
q.title, q.total_answers
|
||||||
|
HAVING
|
||||||
|
COUNT(*) >= 1
|
||||||
|
)
|
||||||
SELECT
|
SELECT
|
||||||
Funnel.count_start_false,
|
Funnel.count_start_false,
|
||||||
Funnel.count_start_true,
|
Funnel.count_start_true,
|
||||||
@ -1679,15 +1685,15 @@ type QuestionsStatisticsParams struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type QuestionsStatisticsRow struct {
|
type QuestionsStatisticsRow struct {
|
||||||
CountStartFalse int64 `db:"count_start_false" json:"count_start_false"`
|
CountStartFalse int64 `db:"count_start_false" json:"count_start_false"`
|
||||||
CountStartTrue int64 `db:"count_start_true" json:"count_start_true"`
|
CountStartTrue int64 `db:"count_start_true" json:"count_start_true"`
|
||||||
CountFResultWithTQuestion int64 `db:"count_f_result_with_t_question" json:"count_f_result_with_t_question"`
|
CountFResultWithTQuestion int64 `db:"count_f_result_with_t_question" json:"count_f_result_with_t_question"`
|
||||||
CountTResult int64 `db:"count_t_result" json:"count_t_result"`
|
CountTResult int64 `db:"count_t_result" json:"count_t_result"`
|
||||||
ResultsTitle string `db:"results_title" json:"results_title"`
|
ResultsTitle string `db:"results_title" json:"results_title"`
|
||||||
ResultsPercentage int32 `db:"results_percentage" json:"results_percentage"`
|
ResultsPercentage int32 `db:"results_percentage" json:"results_percentage"`
|
||||||
QuestionsTitle string `db:"questions_title" json:"questions_title"`
|
QuestionsTitle string `db:"questions_title" json:"questions_title"`
|
||||||
AnswerContent sql.NullString `db:"answer_content" json:"answer_content"`
|
AnswerContent interface{} `db:"answer_content" json:"answer_content"`
|
||||||
QuestionsPercentage int32 `db:"questions_percentage" json:"questions_percentage"`
|
QuestionsPercentage int32 `db:"questions_percentage" json:"questions_percentage"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *Queries) QuestionsStatistics(ctx context.Context, arg QuestionsStatisticsParams) ([]QuestionsStatisticsRow, error) {
|
func (q *Queries) QuestionsStatistics(ctx context.Context, arg QuestionsStatisticsParams) ([]QuestionsStatisticsRow, error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user