mirror of
https://github.com/akvorado/akvorado.git
synced 2025-12-11 22:14:02 +01:00
console: simplify SQL request by computing target resolution in Go
This commit is contained in:
@@ -40,7 +40,7 @@ type graphHandlerOutput struct {
|
||||
// graphHandlerInputToSQL converts a graph input to an SQL request
|
||||
func (input graphHandlerInput) toSQL() (string, error) {
|
||||
interval := int64((input.End.Sub(input.Start).Seconds())) / int64(input.Points)
|
||||
slot := fmt.Sprintf(`max2(intDiv(%d, {resolution})*{resolution}, 1)`, interval)
|
||||
slot := fmt.Sprintf(`{resolution->%d}`, interval)
|
||||
|
||||
// Filter
|
||||
where := input.Filter.filter
|
||||
@@ -105,7 +105,7 @@ GROUP BY time, dimensions
|
||||
ORDER BY time WITH FILL
|
||||
FROM toStartOfInterval({timefilter.Start}, INTERVAL %s second)
|
||||
TO {timefilter.Stop}
|
||||
STEP toUInt32(%s)`, withStr, strings.Join(fields, ",\n "), where, slot, slot)
|
||||
STEP %s`, withStr, strings.Join(fields, ",\n "), where, slot, slot)
|
||||
return sqlQuery, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user