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 int `json:"limit" validate:"min=5"`
|
||||
// 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 bool `json:"bidirectional"`
|
||||
// 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.
|
||||
- `max`: the query focuses on getting the traffic bursts over the time
|
||||
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
|
||||
graphed. It features an auto-completion system that can be triggered manually
|
||||
|
||||
@@ -136,6 +136,7 @@ const limitError = computed(() => {
|
||||
const computationModes = {
|
||||
avg: "Avg",
|
||||
max: "Max",
|
||||
last: "Last",
|
||||
} as const;
|
||||
|
||||
const computationModeList = Object.entries(computationModes).map(
|
||||
|
||||
@@ -20,7 +20,7 @@ type graphCommonHandlerInput struct {
|
||||
End time.Time `json:"end" binding:"required,gtfield=Start"`
|
||||
Dimensions []query.Column `json:"dimensions"` // group by ...
|
||||
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 ...
|
||||
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
|
||||
|
||||
@@ -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)
|
||||
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)
|
||||
lasts := map[int]map[string]int{} // for each axis, a map from row to last(for sorting purpose)
|
||||
lastTimeForAxis := map[int]time.Time{}
|
||||
timeIndexForAxis := map[int]int{}
|
||||
for _, result := range results {
|
||||
@@ -301,6 +302,7 @@ func (c *Component) graphLineHandlerFunc(gc *gin.Context) {
|
||||
points[axis] = map[string][]int{}
|
||||
sums[axis] = map[string]uint64{}
|
||||
maxes[axis] = map[string]uint64{}
|
||||
lasts[axis] = map[string]int{}
|
||||
}
|
||||
if result.Time != lastTime {
|
||||
// New timestamp, increment time index
|
||||
@@ -316,12 +318,14 @@ func (c *Component) graphLineHandlerFunc(gc *gin.Context) {
|
||||
points[axis][rowKey] = row
|
||||
sums[axis][rowKey] = 0
|
||||
maxes[axis][rowKey] = 0
|
||||
lasts[axis][rowKey] = 0
|
||||
}
|
||||
points[axis][rowKey][timeIndexForAxis[axis]] = int(result.Xps)
|
||||
sums[axis][rowKey] += uint64(result.Xps)
|
||||
if uint64(result.Xps) > maxes[axis][rowKey] {
|
||||
maxes[axis][rowKey] = uint64(result.Xps)
|
||||
}
|
||||
lasts[axis][rowKey] = int(result.Xps)
|
||||
}
|
||||
// Sort axes
|
||||
sort.Ints(axes)
|
||||
@@ -344,6 +348,9 @@ func (c *Component) graphLineHandlerFunc(gc *gin.Context) {
|
||||
if input.LimitType == "max" {
|
||||
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]
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user