diff --git a/dal/db_query/queries.sql b/dal/db_query/queries.sql index e8162e2..2a25ec0 100644 --- a/dal/db_query/queries.sql +++ b/dal/db_query/queries.sql @@ -556,6 +556,7 @@ WITH Funnel AS ( answer WHERE quiz_id = $1 + AND start != true AND created_at >= TO_TIMESTAMP($2) AND created_at <= TO_TIMESTAMP($3) GROUP BY @@ -575,6 +576,7 @@ WITH Funnel AS ( JOIN answer a ON q.id = a.question_id WHERE a.quiz_id = $1 + AND a.start != true AND a.created_at >= TO_TIMESTAMP($2) AND a.created_at <= TO_TIMESTAMP($3) GROUP BY diff --git a/dal/sqlcgen/queries.sql.go b/dal/sqlcgen/queries.sql.go index f2a1f03..2d0034b 100644 --- a/dal/sqlcgen/queries.sql.go +++ b/dal/sqlcgen/queries.sql.go @@ -1739,6 +1739,7 @@ WITH Funnel AS ( answer WHERE quiz_id = $1 + AND start != true AND created_at >= TO_TIMESTAMP($2) AND created_at <= TO_TIMESTAMP($3) GROUP BY @@ -1758,6 +1759,7 @@ WITH Funnel AS ( JOIN answer a ON q.id = a.question_id WHERE a.quiz_id = $1 + AND a.start != true AND a.created_at >= TO_TIMESTAMP($2) AND a.created_at <= TO_TIMESTAMP($3) GROUP BY diff --git a/repository/statistics/statistics.go b/repository/statistics/statistics.go index f645530..6495254 100644 --- a/repository/statistics/statistics.go +++ b/repository/statistics/statistics.go @@ -103,6 +103,7 @@ type QuestionsStatsResp struct { // 1 - количество сессий с result == false, но тип вопроса, на который ответ == result / количество сессий с ответом start == true // 2 - количество сессий с ответом result == true / количество сессий с ответом start == true Funnel [3]float64 + FunnelData [4]float64 // ключ - заголовок вопроса найденного по айдишнику вопроса в ответе result == true, // значение - процент ответов с result == true и таким айдишником вопроса Results map[string]float64 @@ -114,6 +115,7 @@ type QuestionsStatsResp struct { func (r *StatisticsRepository) GetQuestionsStatistics(ctx context.Context, req DeviceStatReq) (QuestionsStatsResp, error) { resp := QuestionsStatsResp{ Funnel: [3]float64{}, + FunnelData: [4]float64{}, Results: make(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[1] = float64(row.CountFResultWithTQuestion) / 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