add some data to funnel and filter start from questions
This commit is contained in:
parent
38eec37140
commit
126d5822d5
@ -556,6 +556,7 @@ WITH Funnel AS (
|
|||||||
answer
|
answer
|
||||||
WHERE
|
WHERE
|
||||||
quiz_id = $1
|
quiz_id = $1
|
||||||
|
AND start != true
|
||||||
AND created_at >= TO_TIMESTAMP($2)
|
AND created_at >= TO_TIMESTAMP($2)
|
||||||
AND created_at <= TO_TIMESTAMP($3)
|
AND created_at <= TO_TIMESTAMP($3)
|
||||||
GROUP BY
|
GROUP BY
|
||||||
@ -575,6 +576,7 @@ WITH Funnel AS (
|
|||||||
JOIN answer a ON q.id = a.question_id
|
JOIN answer a ON q.id = a.question_id
|
||||||
WHERE
|
WHERE
|
||||||
a.quiz_id = $1
|
a.quiz_id = $1
|
||||||
|
AND a.start != true
|
||||||
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
|
||||||
|
@ -1739,6 +1739,7 @@ WITH Funnel AS (
|
|||||||
answer
|
answer
|
||||||
WHERE
|
WHERE
|
||||||
quiz_id = $1
|
quiz_id = $1
|
||||||
|
AND start != true
|
||||||
AND created_at >= TO_TIMESTAMP($2)
|
AND created_at >= TO_TIMESTAMP($2)
|
||||||
AND created_at <= TO_TIMESTAMP($3)
|
AND created_at <= TO_TIMESTAMP($3)
|
||||||
GROUP BY
|
GROUP BY
|
||||||
@ -1758,6 +1759,7 @@ WITH Funnel AS (
|
|||||||
JOIN answer a ON q.id = a.question_id
|
JOIN answer a ON q.id = a.question_id
|
||||||
WHERE
|
WHERE
|
||||||
a.quiz_id = $1
|
a.quiz_id = $1
|
||||||
|
AND a.start != true
|
||||||
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
|
||||||
|
@ -103,6 +103,7 @@ type QuestionsStatsResp struct {
|
|||||||
// 1 - количество сессий с result == false, но тип вопроса, на который ответ == result / количество сессий с ответом start == true
|
// 1 - количество сессий с result == false, но тип вопроса, на который ответ == result / количество сессий с ответом start == true
|
||||||
// 2 - количество сессий с ответом result == true / количество сессий с ответом start == true
|
// 2 - количество сессий с ответом result == true / количество сессий с ответом start == true
|
||||||
Funnel [3]float64
|
Funnel [3]float64
|
||||||
|
FunnelData [4]float64
|
||||||
// ключ - заголовок вопроса найденного по айдишнику вопроса в ответе result == true,
|
// ключ - заголовок вопроса найденного по айдишнику вопроса в ответе result == true,
|
||||||
// значение - процент ответов с result == true и таким айдишником вопроса
|
// значение - процент ответов с result == true и таким айдишником вопроса
|
||||||
Results map[string]float64
|
Results map[string]float64
|
||||||
@ -114,6 +115,7 @@ type QuestionsStatsResp struct {
|
|||||||
func (r *StatisticsRepository) GetQuestionsStatistics(ctx context.Context, req DeviceStatReq) (QuestionsStatsResp, error) {
|
func (r *StatisticsRepository) GetQuestionsStatistics(ctx context.Context, req DeviceStatReq) (QuestionsStatsResp, error) {
|
||||||
resp := QuestionsStatsResp{
|
resp := QuestionsStatsResp{
|
||||||
Funnel: [3]float64{},
|
Funnel: [3]float64{},
|
||||||
|
FunnelData: [4]float64{},
|
||||||
Results: make(map[string]float64),
|
Results: make(map[string]float64),
|
||||||
Questions: make(map[string]map[string]float64),
|
Questions: make(map[string]map[string]float64),
|
||||||
}
|
}
|
||||||
@ -132,6 +134,10 @@ func (r *StatisticsRepository) GetQuestionsStatistics(ctx context.Context, req D
|
|||||||
resp.Funnel[0] = float64(row.CountStartFalse) / float64(row.CountStartTrue)
|
resp.Funnel[0] = float64(row.CountStartFalse) / float64(row.CountStartTrue)
|
||||||
resp.Funnel[1] = float64(row.CountFResultWithTQuestion) / float64(row.CountStartTrue)
|
resp.Funnel[1] = float64(row.CountFResultWithTQuestion) / float64(row.CountStartTrue)
|
||||||
resp.Funnel[2] = float64(row.CountTResult) / float64(row.CountStartTrue)
|
resp.Funnel[2] = float64(row.CountTResult) / float64(row.CountStartTrue)
|
||||||
|
resp.FunnelData[0] = float64(row.CountStartTrue)
|
||||||
|
resp.FunnelData[1] = float64(row.CountStartFalse)
|
||||||
|
resp.FunnelData[2] = float64(row.CountFResultWithTQuestion)
|
||||||
|
resp.FunnelData[3] = float64(row.CountTResult)
|
||||||
}
|
}
|
||||||
|
|
||||||
resp.Results[row.ResultsTitle] = row.ResultsPercentage
|
resp.Results[row.ResultsTitle] = row.ResultsPercentage
|
||||||
|
Loading…
Reference in New Issue
Block a user