diff --git a/dal/db_query/queries.sql b/dal/db_query/queries.sql index 3f9c2a9..5677042 100644 --- a/dal/db_query/queries.sql +++ b/dal/db_query/queries.sql @@ -375,11 +375,11 @@ WITH DeviceStats AS ( ) SELECT DeviceStats.device_type, - CAST((DeviceStats.device_count::FLOAT / TotalStats.total_count) * 100.0 AS INT) AS device_percentage, + CAST((DeviceStats.device_count::FLOAT / TotalStats.total_count) * 100.0 AS FLOAT8) AS device_percentage, OSStats.os, - CAST((OSStats.os_count::FLOAT / TotalStats.total_count) * 100.0 AS INT) AS os_percentage, + CAST((OSStats.os_count::FLOAT / TotalStats.total_count) * 100.0 AS FLOAT8) AS os_percentage, BrowserStats.browser, - CAST((BrowserStats.browser_count::FLOAT / TotalStats.total_count) * 100.0 AS INT) AS browser_percentage + CAST((BrowserStats.browser_count::FLOAT / TotalStats.total_count) * 100.0 AS FLOAT8) AS browser_percentage FROM DeviceStats, OSStats, diff --git a/repository/statistics/statistics.go b/repository/statistics/statistics.go index 686e089..382c1f5 100644 --- a/repository/statistics/statistics.go +++ b/repository/statistics/statistics.go @@ -32,17 +32,17 @@ type DeviceStatReq struct { type DeviceStatResp struct { //ключ DeviceType значение процент - Device map[string]int32 // процентное соотношение DeviceType по всем ответам на опроc c res==true + Device map[string]float64 // процентное соотношение DeviceType по всем ответам на опроc c res==true // тоже самое тут только по OS и BROWSER - OS map[string]int32 - Browser map[string]int32 + OS map[string]float64 + Browser map[string]float64 } func (r *StatisticsRepository) GetDeviceStatistics(ctx context.Context, req DeviceStatReq) (DeviceStatResp, error) { resp := DeviceStatResp{ - Device: make(map[string]int32), - OS: make(map[string]int32), - Browser: make(map[string]int32), + Device: make(map[string]float64), + OS: make(map[string]float64), + Browser: make(map[string]float64), } allStatistics, err := r.queries.DeviceStatistics(ctx, sqlcgen.DeviceStatisticsParams{