mirror of
https://github.com/akvorado/akvorado.git
synced 2025-12-11 22:14:02 +01:00
feat/console: option to sort by last column
This commit is contained in:
committed by
Vincent Bernat
parent
8686e1cbd2
commit
708889d558
@@ -70,7 +70,7 @@ type VisualizeOptionsConfiguration struct {
|
|||||||
// Limit is the default limit to use
|
// Limit is the default limit to use
|
||||||
Limit int `json:"limit" validate:"min=5"`
|
Limit int `json:"limit" validate:"min=5"`
|
||||||
// LimitType is the default limitType to use
|
// LimitType is the default limitType to use
|
||||||
LimitType string `json:"limitType" validate:"oneof=avg max"`
|
LimitType string `json:"limitType" validate:"oneof=avg max last"`
|
||||||
// Bidirectional tells if a graph should be bidirectional (all except sankey)
|
// Bidirectional tells if a graph should be bidirectional (all except sankey)
|
||||||
Bidirectional bool `json:"bidirectional"`
|
Bidirectional bool `json:"bidirectional"`
|
||||||
// PreviousPeriod tells if a graph should display the previous period (for stacked)
|
// PreviousPeriod tells if a graph should display the previous period (for stacked)
|
||||||
|
|||||||
@@ -157,6 +157,8 @@ aspect of the graph.
|
|||||||
traffics over the time selection.
|
traffics over the time selection.
|
||||||
- `max`: the query focuses on getting the traffic bursts over the time
|
- `max`: the query focuses on getting the traffic bursts over the time
|
||||||
selection.
|
selection.
|
||||||
|
- `last`: the query focuses on getting the most recent (last) traffic over
|
||||||
|
the time selection.
|
||||||
|
|
||||||
- The filter box contains an SQL-like expression to limit the data to be
|
- The filter box contains an SQL-like expression to limit the data to be
|
||||||
graphed. It features an auto-completion system that can be triggered manually
|
graphed. It features an auto-completion system that can be triggered manually
|
||||||
|
|||||||
@@ -136,6 +136,7 @@ const limitError = computed(() => {
|
|||||||
const computationModes = {
|
const computationModes = {
|
||||||
avg: "Avg",
|
avg: "Avg",
|
||||||
max: "Max",
|
max: "Max",
|
||||||
|
last: "Last",
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
const computationModeList = Object.entries(computationModes).map(
|
const computationModeList = Object.entries(computationModes).map(
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ type graphCommonHandlerInput struct {
|
|||||||
End time.Time `json:"end" binding:"required,gtfield=Start"`
|
End time.Time `json:"end" binding:"required,gtfield=Start"`
|
||||||
Dimensions []query.Column `json:"dimensions"` // group by ...
|
Dimensions []query.Column `json:"dimensions"` // group by ...
|
||||||
Limit int `json:"limit" binding:"min=1"` // limit product of dimensions
|
Limit int `json:"limit" binding:"min=1"` // limit product of dimensions
|
||||||
LimitType string `json:"limitType" validate:"oneof=avg max"`
|
LimitType string `json:"limitType" validate:"oneof=avg max last"`
|
||||||
Filter query.Filter `json:"filter"` // where ...
|
Filter query.Filter `json:"filter"` // where ...
|
||||||
TruncateAddrV4 int `json:"truncate-v4" binding:"min=0,max=32"` // 0 or 32 = no truncation
|
TruncateAddrV4 int `json:"truncate-v4" binding:"min=0,max=32"` // 0 or 32 = no truncation
|
||||||
TruncateAddrV6 int `json:"truncate-v6" binding:"min=0,max=128"` // 0 or 128 = no truncation
|
TruncateAddrV6 int `json:"truncate-v6" binding:"min=0,max=128"` // 0 or 128 = no truncation
|
||||||
|
|||||||
@@ -286,6 +286,7 @@ func (c *Component) graphLineHandlerFunc(gc *gin.Context) {
|
|||||||
points := map[int]map[string][]int{} // for each axis, a map from row to list of points (one point per ts)
|
points := map[int]map[string][]int{} // for each axis, a map from row to list of points (one point per ts)
|
||||||
sums := map[int]map[string]uint64{} // for each axis, a map from row to sum (for sorting purpose)
|
sums := map[int]map[string]uint64{} // for each axis, a map from row to sum (for sorting purpose)
|
||||||
maxes := map[int]map[string]uint64{} // for each axis, a map from row to max (for sorting purpose)
|
maxes := map[int]map[string]uint64{} // for each axis, a map from row to max (for sorting purpose)
|
||||||
|
lasts := map[int]map[string]int{} // for each axis, a map from row to last(for sorting purpose)
|
||||||
lastTimeForAxis := map[int]time.Time{}
|
lastTimeForAxis := map[int]time.Time{}
|
||||||
timeIndexForAxis := map[int]int{}
|
timeIndexForAxis := map[int]int{}
|
||||||
for _, result := range results {
|
for _, result := range results {
|
||||||
@@ -301,6 +302,7 @@ func (c *Component) graphLineHandlerFunc(gc *gin.Context) {
|
|||||||
points[axis] = map[string][]int{}
|
points[axis] = map[string][]int{}
|
||||||
sums[axis] = map[string]uint64{}
|
sums[axis] = map[string]uint64{}
|
||||||
maxes[axis] = map[string]uint64{}
|
maxes[axis] = map[string]uint64{}
|
||||||
|
lasts[axis] = map[string]int{}
|
||||||
}
|
}
|
||||||
if result.Time != lastTime {
|
if result.Time != lastTime {
|
||||||
// New timestamp, increment time index
|
// New timestamp, increment time index
|
||||||
@@ -316,12 +318,14 @@ func (c *Component) graphLineHandlerFunc(gc *gin.Context) {
|
|||||||
points[axis][rowKey] = row
|
points[axis][rowKey] = row
|
||||||
sums[axis][rowKey] = 0
|
sums[axis][rowKey] = 0
|
||||||
maxes[axis][rowKey] = 0
|
maxes[axis][rowKey] = 0
|
||||||
|
lasts[axis][rowKey] = 0
|
||||||
}
|
}
|
||||||
points[axis][rowKey][timeIndexForAxis[axis]] = int(result.Xps)
|
points[axis][rowKey][timeIndexForAxis[axis]] = int(result.Xps)
|
||||||
sums[axis][rowKey] += uint64(result.Xps)
|
sums[axis][rowKey] += uint64(result.Xps)
|
||||||
if uint64(result.Xps) > maxes[axis][rowKey] {
|
if uint64(result.Xps) > maxes[axis][rowKey] {
|
||||||
maxes[axis][rowKey] = uint64(result.Xps)
|
maxes[axis][rowKey] = uint64(result.Xps)
|
||||||
}
|
}
|
||||||
|
lasts[axis][rowKey] = int(result.Xps)
|
||||||
}
|
}
|
||||||
// Sort axes
|
// Sort axes
|
||||||
sort.Ints(axes)
|
sort.Ints(axes)
|
||||||
@@ -344,6 +348,9 @@ func (c *Component) graphLineHandlerFunc(gc *gin.Context) {
|
|||||||
if input.LimitType == "max" {
|
if input.LimitType == "max" {
|
||||||
return maxes[axis][iKey] > maxes[axis][jKey]
|
return maxes[axis][iKey] > maxes[axis][jKey]
|
||||||
}
|
}
|
||||||
|
if input.LimitType == "last" {
|
||||||
|
return lasts[axis][iKey] > lasts[axis][jKey]
|
||||||
|
}
|
||||||
|
|
||||||
return sums[axis][iKey] > sums[axis][jKey]
|
return sums[axis][iKey] > sums[axis][jKey]
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user