change some types
This commit is contained in:
parent
b5c3002f4e
commit
32b57399b0
@ -32,17 +32,17 @@ type DeviceStatReq struct {
|
|||||||
|
|
||||||
type DeviceStatResp struct {
|
type DeviceStatResp struct {
|
||||||
//ключ DeviceType значение процент
|
//ключ DeviceType значение процент
|
||||||
Device map[string]float64 // процентное соотношение DeviceType по всем ответам на опроc c res==true
|
Device map[string]int32 // процентное соотношение DeviceType по всем ответам на опроc c res==true
|
||||||
// тоже самое тут только по OS и BROWSER
|
// тоже самое тут только по OS и BROWSER
|
||||||
OS map[string]float64
|
OS map[string]int32
|
||||||
Browser map[string]float64
|
Browser map[string]int32
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *StatisticsRepository) GetDeviceStatistics(ctx context.Context, req DeviceStatReq) (DeviceStatResp, error) {
|
func (r *StatisticsRepository) GetDeviceStatistics(ctx context.Context, req DeviceStatReq) (DeviceStatResp, error) {
|
||||||
resp := DeviceStatResp{
|
resp := DeviceStatResp{
|
||||||
Device: make(map[string]float64),
|
Device: make(map[string]int32),
|
||||||
OS: make(map[string]float64),
|
OS: make(map[string]int32),
|
||||||
Browser: make(map[string]float64),
|
Browser: make(map[string]int32),
|
||||||
}
|
}
|
||||||
|
|
||||||
allStatistics, err := r.queries.DeviceStatistics(ctx, sqlcgen.DeviceStatisticsParams{
|
allStatistics, err := r.queries.DeviceStatistics(ctx, sqlcgen.DeviceStatisticsParams{
|
||||||
@ -55,27 +55,27 @@ func (r *StatisticsRepository) GetDeviceStatistics(ctx context.Context, req Devi
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, stat := range allStatistics {
|
for _, stat := range allStatistics {
|
||||||
resp.Device[stat.DeviceType] = float64(stat.DevicePercentage)
|
resp.Device[stat.DeviceType] = stat.DevicePercentage
|
||||||
resp.OS[stat.Os] = float64(stat.OsPercentage)
|
resp.OS[stat.Os] = stat.OsPercentage
|
||||||
resp.Browser[stat.Browser] = float64(stat.BrowserPercentage)
|
resp.Browser[stat.Browser] = stat.BrowserPercentage
|
||||||
}
|
}
|
||||||
|
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type GeneralStatsResp struct {
|
type GeneralStatsResp struct {
|
||||||
Open map[uint64]uint64 // количество ответов с полем start == true за период от одного пункта разбиения и до другого
|
Open map[int64]int64 // количество ответов с полем start == true за период от одного пункта разбиения и до другого
|
||||||
Result map[uint64]uint64 // количество ответов с полем result == true за период от одного пункта разбиения и до другого
|
Result map[int64]int64 // количество ответов с полем result == true за период от одного пункта разбиения и до другого
|
||||||
AvTime map[uint64]uint64 // среднее время между ответом с полем result == true и start == true. в рамках сессии
|
AvTime map[int64]uint64 // среднее время между ответом с полем result == true и start == true. в рамках сессии
|
||||||
Conversion map[uint64]uint64 // Result/Open за период от одного пункта разбиения и до другого
|
Conversion map[int64]int32 // Result/Open за период от одного пункта разбиения и до другого
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *StatisticsRepository) GetGeneralStatistics(ctx context.Context, req DeviceStatReq) (GeneralStatsResp, error) {
|
func (r *StatisticsRepository) GetGeneralStatistics(ctx context.Context, req DeviceStatReq) (GeneralStatsResp, error) {
|
||||||
resp := GeneralStatsResp{
|
resp := GeneralStatsResp{
|
||||||
Open: make(map[uint64]uint64),
|
Open: make(map[int64]int64),
|
||||||
Result: make(map[uint64]uint64),
|
Result: make(map[int64]int64),
|
||||||
AvTime: make(map[uint64]uint64),
|
AvTime: make(map[int64]uint64),
|
||||||
Conversion: make(map[uint64]uint64),
|
Conversion: make(map[int64]int32),
|
||||||
}
|
}
|
||||||
// todo затестить запрос нужно, когда на один тру ответ приходится один тру старт апдейтнуть запрос
|
// todo затестить запрос нужно, когда на один тру ответ приходится один тру старт апдейтнуть запрос
|
||||||
allStatistics, err := r.queries.GeneralStatistics(ctx, sqlcgen.GeneralStatisticsParams{
|
allStatistics, err := r.queries.GeneralStatistics(ctx, sqlcgen.GeneralStatisticsParams{
|
||||||
@ -88,11 +88,29 @@ func (r *StatisticsRepository) GetGeneralStatistics(ctx context.Context, req Dev
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, stat := range allStatistics {
|
for _, stat := range allStatistics {
|
||||||
resp.Open[uint64(stat.TimeBucket.Unix())] = uint64(stat.OpenCount)
|
resp.Open[stat.TimeBucket.Unix()] = stat.OpenCount
|
||||||
resp.Result[uint64(stat.TimeBucket.Unix())] = uint64(stat.ResultCount)
|
resp.Result[stat.TimeBucket.Unix()] = stat.ResultCount
|
||||||
resp.AvTime[uint64(stat.TimeBucket.Unix())] = uint64(stat.AvgTime)
|
resp.AvTime[stat.TimeBucket.Unix()] = uint64(stat.AvgTime)
|
||||||
resp.Conversion[uint64(stat.TimeBucket.Unix())] = uint64(stat.Conversion)
|
resp.Conversion[stat.TimeBucket.Unix()] = stat.Conversion
|
||||||
}
|
}
|
||||||
|
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type QuestionsStatsResp struct {
|
||||||
|
//Funnel 3 отдельных метрики
|
||||||
|
// 0 - количество сессий с любым ответом кроме start == true / количество сессий с ответом start == true
|
||||||
|
// 1 - количество сессий с result == false, но тип вопроса, на который ответ == result / количество сессий с ответом start == true
|
||||||
|
// 2 - количество сессий с ответом result == true / количество сессий с ответом start == true
|
||||||
|
Funnel [3]float64
|
||||||
|
// ключ - заголовок вопроса найденного по айдишнику вопроса в ответе result == true,
|
||||||
|
// значение - процент ответов с result == true и таким айдишником вопроса
|
||||||
|
Results map[string]float64
|
||||||
|
// ключ - заголовок вопроса, а значение - map, где ключ - вариант ответа на этот вопрос,
|
||||||
|
// т.е. группировка по полю Контент, а значение - процент таких ответов
|
||||||
|
Questions map[string]map[string]float64
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *StatisticsRepository) GetQuestionsStatistics(ctx context.Context, req DeviceStatReq) (QuestionsStatsResp, error) {
|
||||||
|
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user