update repo method

This commit is contained in:
Pavel 2024-03-17 19:38:19 +03:00
parent c349706f27
commit 48725054c7
2 changed files with 5 additions and 5 deletions

@ -485,7 +485,6 @@ WITH Funnel AS (
COUNT(DISTINCT a.session) FILTER (WHERE a.start = FALSE) AS count_start_false, COUNT(DISTINCT a.session) FILTER (WHERE a.start = FALSE) AS count_start_false,
COUNT(DISTINCT a.session) FILTER (WHERE a.start = TRUE) AS count_start_true, COUNT(DISTINCT a.session) FILTER (WHERE a.start = TRUE) AS count_start_true,
COUNT(DISTINCT CASE WHEN a.result = FALSE AND qid_true_result IS NOT NULL THEN a.session END) AS count_f_result_with_t_question, COUNT(DISTINCT CASE WHEN a.result = FALSE AND qid_true_result IS NOT NULL THEN a.session END) AS count_f_result_with_t_question,
COUNT(DISTINCT CASE WHEN a.start = TRUE AND qid_true_result IS NULL THEN a.session END) AS count_t_start_with_t_question,
COUNT(DISTINCT a.session) FILTER (WHERE a.result = TRUE) AS count_t_result COUNT(DISTINCT a.session) FILTER (WHERE a.result = TRUE) AS count_t_result
FROM FROM
answer a answer a
@ -571,7 +570,6 @@ SELECT
Funnel.count_start_false, Funnel.count_start_false,
Funnel.count_start_true, Funnel.count_start_true,
Funnel.count_f_result_with_t_question, Funnel.count_f_result_with_t_question,
Funnel.count_t_start_with_t_question,
Funnel.count_t_result, Funnel.count_t_result,
Results.question_title AS results_title, Results.question_title AS results_title,
Results.percentage AS results_percentage, Results.percentage AS results_percentage,

@ -130,9 +130,11 @@ func (r *StatisticsRepository) GetQuestionsStatistics(ctx context.Context, req D
} }
for _, row := range queStatistics { for _, row := range queStatistics {
resp.Funnel[0] = float64(row.CountStartFalse) / float64(row.CountStartTrue) if row.CountStartTrue != 0 {
resp.Funnel[1] = float64(row.CountFResultWithTQuestion) / float64(row.CountStartTrue) resp.Funnel[0] = float64(row.CountStartFalse) / float64(row.CountStartTrue)
resp.Funnel[2] = float64(row.CountTResult) / float64(row.CountStartTrue) resp.Funnel[1] = float64(row.CountFResultWithTQuestion) / float64(row.CountStartTrue)
resp.Funnel[2] = float64(row.CountTResult) / float64(row.CountStartTrue)
}
fmt.Println(resp.Funnel) fmt.Println(resp.Funnel)
resp.Results[row.ResultsTitle] = float64(row.ResultsPercentage) resp.Results[row.ResultsTitle] = float64(row.ResultsPercentage)