update sqlc gen

This commit is contained in:
Pavel 2024-03-17 19:23:42 +03:00
parent e2ae058c47
commit 153d15351a
2 changed files with 71 additions and 55 deletions

@ -518,7 +518,10 @@ WITH Funnel AS (
SELECT SELECT
q.title AS question_title, q.title AS question_title,
ta.total_answers, ta.total_answers,
COUNT(*)::FLOAT / NULLIF(ta.total_answers, 0) AS percentage CASE
WHEN ta.total_answers = 0 THEN NULL
ELSE COUNT(*)::FLOAT / NULLIF(ta.total_answers, 0)
END AS percentage
FROM FROM
answer a answer a
JOIN JOIN
@ -540,7 +543,10 @@ WITH Funnel AS (
q.id, q.id,
q.title AS question_title, q.title AS question_title,
a.content AS answer_content, a.content AS answer_content,
CAST(COUNT(*)::FLOAT / NULLIF(q.total_answers, 0) AS INTEGER) AS percentage CASE
WHEN q.total_answers = 0 THEN NULL
ELSE COUNT(*)::FLOAT / NULLIF(q.total_answers, 0)
END AS percentage
FROM FROM
answer a answer a
JOIN ( JOIN (
@ -575,4 +581,6 @@ SELECT
FROM FROM
Funnel, Funnel,
Results, Results,
Questions; Questions
WHERE
Questions.percentage >= 1;

@ -1612,7 +1612,10 @@ WITH Funnel AS (
SELECT SELECT
q.title AS question_title, q.title AS question_title,
ta.total_answers, ta.total_answers,
COUNT(*)::FLOAT / NULLIF(ta.total_answers, 0) AS percentage CASE
WHEN ta.total_answers = 0 THEN NULL
ELSE COUNT(*)::FLOAT / NULLIF(ta.total_answers, 0)
END AS percentage
FROM FROM
answer a answer a
JOIN JOIN
@ -1634,7 +1637,10 @@ WITH Funnel AS (
q.id, q.id,
q.title AS question_title, q.title AS question_title,
a.content AS answer_content, a.content AS answer_content,
CAST(COUNT(*)::FLOAT / NULLIF(q.total_answers, 0) AS INTEGER) AS percentage CASE
WHEN q.total_answers = 0 THEN NULL
ELSE COUNT(*)::FLOAT / NULLIF(q.total_answers, 0)
END AS percentage
FROM FROM
answer a answer a
JOIN ( JOIN (
@ -1670,6 +1676,8 @@ FROM
Funnel, Funnel,
Results, Results,
Questions Questions
WHERE
Questions.percentage >= 1
` `
type QuestionsStatisticsParams struct { type QuestionsStatisticsParams struct {
@ -1685,10 +1693,10 @@ type QuestionsStatisticsRow struct {
CountTStartWithTQuestion int64 `db:"count_t_start_with_t_question" json:"count_t_start_with_t_question"` CountTStartWithTQuestion int64 `db:"count_t_start_with_t_question" json:"count_t_start_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 interface{} `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 sql.NullString `db:"answer_content" json:"answer_content"`
QuestionsPercentage int32 `db:"questions_percentage" json:"questions_percentage"` QuestionsPercentage interface{} `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) {