lil fix question title
This commit is contained in:
parent
126d5822d5
commit
4495237cb3
@ -566,6 +566,7 @@ WITH Funnel AS (
|
|||||||
Questions AS (
|
Questions AS (
|
||||||
SELECT
|
SELECT
|
||||||
q.title AS question_title,
|
q.title AS question_title,
|
||||||
|
q.page AS question_page,
|
||||||
lc.last_answer_content AS answer_content,
|
lc.last_answer_content AS answer_content,
|
||||||
CAST(
|
CAST(
|
||||||
COUNT(CASE WHEN a.result = FALSE THEN 1 END) * 100.0 / NULLIF(SUM(COUNT(CASE WHEN a.result = FALSE THEN 1 END)) OVER (PARTITION BY q.id), 0) AS FLOAT8
|
COUNT(CASE WHEN a.result = FALSE THEN 1 END) * 100.0 / NULLIF(SUM(COUNT(CASE WHEN a.result = FALSE THEN 1 END)) OVER (PARTITION BY q.id), 0) AS FLOAT8
|
||||||
@ -592,6 +593,7 @@ SELECT
|
|||||||
Results.question_title AS results_title,
|
Results.question_title AS results_title,
|
||||||
Results.percentage AS results_percentage,
|
Results.percentage AS results_percentage,
|
||||||
Questions.question_title AS questions_title,
|
Questions.question_title AS questions_title,
|
||||||
|
COALESCE(Questions.question_page, 0) AS questions_page,
|
||||||
Questions.answer_content AS answer_content,
|
Questions.answer_content AS answer_content,
|
||||||
Questions.percentage AS questions_percentage
|
Questions.percentage AS questions_percentage
|
||||||
FROM
|
FROM
|
||||||
|
@ -1749,6 +1749,7 @@ WITH Funnel AS (
|
|||||||
Questions AS (
|
Questions AS (
|
||||||
SELECT
|
SELECT
|
||||||
q.title AS question_title,
|
q.title AS question_title,
|
||||||
|
q.page AS question_page,
|
||||||
lc.last_answer_content AS answer_content,
|
lc.last_answer_content AS answer_content,
|
||||||
CAST(
|
CAST(
|
||||||
COUNT(CASE WHEN a.result = FALSE THEN 1 END) * 100.0 / NULLIF(SUM(COUNT(CASE WHEN a.result = FALSE THEN 1 END)) OVER (PARTITION BY q.id), 0) AS FLOAT8
|
COUNT(CASE WHEN a.result = FALSE THEN 1 END) * 100.0 / NULLIF(SUM(COUNT(CASE WHEN a.result = FALSE THEN 1 END)) OVER (PARTITION BY q.id), 0) AS FLOAT8
|
||||||
@ -1775,6 +1776,7 @@ SELECT
|
|||||||
Results.question_title AS results_title,
|
Results.question_title AS results_title,
|
||||||
Results.percentage AS results_percentage,
|
Results.percentage AS results_percentage,
|
||||||
Questions.question_title AS questions_title,
|
Questions.question_title AS questions_title,
|
||||||
|
COALESCE(Questions.question_page, 0) AS questions_page,
|
||||||
Questions.answer_content AS answer_content,
|
Questions.answer_content AS answer_content,
|
||||||
Questions.percentage AS questions_percentage
|
Questions.percentage AS questions_percentage
|
||||||
FROM
|
FROM
|
||||||
@ -1799,6 +1801,7 @@ type QuestionsStatisticsRow struct {
|
|||||||
ResultsTitle string `db:"results_title" json:"results_title"`
|
ResultsTitle string `db:"results_title" json:"results_title"`
|
||||||
ResultsPercentage float64 `db:"results_percentage" json:"results_percentage"`
|
ResultsPercentage float64 `db:"results_percentage" json:"results_percentage"`
|
||||||
QuestionsTitle string `db:"questions_title" json:"questions_title"`
|
QuestionsTitle string `db:"questions_title" json:"questions_title"`
|
||||||
|
QuestionsPage int16 `db:"questions_page" json:"questions_page"`
|
||||||
AnswerContent sql.NullString `db:"answer_content" json:"answer_content"`
|
AnswerContent sql.NullString `db:"answer_content" json:"answer_content"`
|
||||||
QuestionsPercentage float64 `db:"questions_percentage" json:"questions_percentage"`
|
QuestionsPercentage float64 `db:"questions_percentage" json:"questions_percentage"`
|
||||||
}
|
}
|
||||||
@ -1820,6 +1823,7 @@ func (q *Queries) QuestionsStatistics(ctx context.Context, arg QuestionsStatisti
|
|||||||
&i.ResultsTitle,
|
&i.ResultsTitle,
|
||||||
&i.ResultsPercentage,
|
&i.ResultsPercentage,
|
||||||
&i.QuestionsTitle,
|
&i.QuestionsTitle,
|
||||||
|
&i.QuestionsPage,
|
||||||
&i.AnswerContent,
|
&i.AnswerContent,
|
||||||
&i.QuestionsPercentage,
|
&i.QuestionsPercentage,
|
||||||
); err != nil {
|
); err != nil {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package statistics
|
package statistics
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"context"
|
"context"
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"penahub.gitlab.yandexcloud.net/backend/quiz/common.git/dal/sqlcgen"
|
"penahub.gitlab.yandexcloud.net/backend/quiz/common.git/dal/sqlcgen"
|
||||||
@ -142,10 +143,11 @@ func (r *StatisticsRepository) GetQuestionsStatistics(ctx context.Context, req D
|
|||||||
|
|
||||||
resp.Results[row.ResultsTitle] = row.ResultsPercentage
|
resp.Results[row.ResultsTitle] = row.ResultsPercentage
|
||||||
|
|
||||||
if resp.Questions[row.QuestionsTitle] == nil {
|
questionTitle := fmt.Sprintf("%s (%d)", row.QuestionsTitle, row.QuestionsPage)
|
||||||
resp.Questions[row.QuestionsTitle] = make(map[string]float64)
|
if resp.Questions[questionTitle] == nil {
|
||||||
|
resp.Questions[questionTitle] = make(map[string]float64)
|
||||||
}
|
}
|
||||||
resp.Questions[row.QuestionsTitle][row.AnswerContent.String] = row.QuestionsPercentage
|
resp.Questions[questionTitle][row.AnswerContent.String] = row.QuestionsPercentage
|
||||||
}
|
}
|
||||||
|
|
||||||
return resp, nil
|
return resp, nil
|
||||||
|
Loading…
Reference in New Issue
Block a user