fix trains/busses/...
This commit is contained in:
parent
456f17474b
commit
954b6c784f
22
bot.go
22
bot.go
@ -110,8 +110,8 @@ func (b *Bot) BotHandlers() {
|
|||||||
b.bot.Handle("/value", botGraphValue)
|
b.bot.Handle("/value", botGraphValue)
|
||||||
b.bot.Handle("/value_delta", botGraphValueDelta)
|
b.bot.Handle("/value_delta", botGraphValueDelta)
|
||||||
b.bot.Handle("/planes", botGraphPlanes)
|
b.bot.Handle("/planes", botGraphPlanes)
|
||||||
b.bot.Handle("/busses", botGraphPlanes)
|
b.bot.Handle("/busses", botGraphBusses)
|
||||||
b.bot.Handle("/trains", botGraphPlanes)
|
b.bot.Handle("/trains", botGraphTrains)
|
||||||
|
|
||||||
b.bot.Handle(tb.OnPhoto, botPhoto)
|
b.bot.Handle(tb.OnPhoto, botPhoto)
|
||||||
b.bot.Handle(tb.OnChannelPost, botChannelPost)
|
b.bot.Handle(tb.OnChannelPost, botChannelPost)
|
||||||
@ -984,6 +984,7 @@ func botGraphValue(m *tb.Message) {
|
|||||||
|
|
||||||
func botGraphValueDelta(m *tb.Message) {
|
func botGraphValueDelta(m *tb.Message) {
|
||||||
var (
|
var (
|
||||||
|
minZero int
|
||||||
maxVal float64
|
maxVal float64
|
||||||
unitFactor float64
|
unitFactor float64
|
||||||
unitName string
|
unitName string
|
||||||
@ -1008,6 +1009,9 @@ func botGraphValueDelta(m *tb.Message) {
|
|||||||
vals[coID] = append(vals[coID], pt)
|
vals[coID] = append(vals[coID], pt)
|
||||||
}
|
}
|
||||||
sort.Slice(vals[coID], func(i, j int) bool { return vals[coID][i].X < vals[coID][j].X })
|
sort.Slice(vals[coID], func(i, j int) bool { return vals[coID][i].X < vals[coID][j].X })
|
||||||
|
if len(vals[coID]) > minZero {
|
||||||
|
minZero = len(vals[coID])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1017,9 +1021,21 @@ func botGraphValueDelta(m *tb.Message) {
|
|||||||
if math.Abs(v[i].Y) > maxVal {
|
if math.Abs(v[i].Y) > maxVal {
|
||||||
maxVal = math.Abs(v[i].Y)
|
maxVal = math.Abs(v[i].Y)
|
||||||
}
|
}
|
||||||
|
if v[i].Y == 0 && i < minZero {
|
||||||
|
minZero = i
|
||||||
|
}
|
||||||
}
|
}
|
||||||
vals[coID] = v[1:]
|
vals[coID] = v
|
||||||
}
|
}
|
||||||
|
for coID, v := range vals {
|
||||||
|
if minZero > 1 {
|
||||||
|
vals[coID] = v[minZero:]
|
||||||
|
} else {
|
||||||
|
vals[coID] = v[1:]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
logInfoDebug("botGraphValueDelta : removing leading %d values", minZero)
|
||||||
|
|
||||||
if maxVal > 1000000000 {
|
if maxVal > 1000000000 {
|
||||||
unitFactor = 1000000000
|
unitFactor = 1000000000
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// Code generated by version.sh (@generated) DO NOT EDIT.
|
// Code generated by version.sh (@generated) DO NOT EDIT.
|
||||||
package main
|
package main
|
||||||
var githash = "2a1bf10"
|
var githash = "456f174"
|
||||||
var buildstamp = "2021-12-06_14:22:55"
|
var buildstamp = "2021-12-06_14:34:11"
|
||||||
var commits = "235"
|
var commits = "236"
|
||||||
var version = "2a1bf10-b235 - 2021-12-06_14:22:55"
|
var version = "456f174-b236 - 2021-12-06_14:34:11"
|
||||||
|
Loading…
Reference in New Issue
Block a user