change type int to float
This commit is contained in:
parent
1051d9c504
commit
47da9211e6
@ -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,
|
||||
|
@ -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{
|
||||
|
Loading…
Reference in New Issue
Block a user