diff --git a/bot.go b/bot.go index e48d923..90e9e02 100644 --- a/bot.go +++ b/bot.go @@ -110,8 +110,8 @@ func (b *Bot) BotHandlers() { b.bot.Handle("/value", botGraphValue) b.bot.Handle("/value_delta", botGraphValueDelta) b.bot.Handle("/planes", botGraphPlanes) - b.bot.Handle("/busses", botGraphPlanes) - b.bot.Handle("/trains", botGraphPlanes) + b.bot.Handle("/busses", botGraphBusses) + b.bot.Handle("/trains", botGraphTrains) b.bot.Handle(tb.OnPhoto, botPhoto) b.bot.Handle(tb.OnChannelPost, botChannelPost) @@ -984,6 +984,7 @@ func botGraphValue(m *tb.Message) { func botGraphValueDelta(m *tb.Message) { var ( + minZero int maxVal float64 unitFactor float64 unitName string @@ -1008,6 +1009,9 @@ func botGraphValueDelta(m *tb.Message) { vals[coID] = append(vals[coID], pt) } 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 { 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 { unitFactor = 1000000000 diff --git a/version.go b/version.go index 476fa34..66f6694 100644 --- a/version.go +++ b/version.go @@ -1,6 +1,6 @@ // Code generated by version.sh (@generated) DO NOT EDIT. package main -var githash = "2a1bf10" -var buildstamp = "2021-12-06_14:22:55" -var commits = "235" -var version = "2a1bf10-b235 - 2021-12-06_14:22:55" +var githash = "456f174" +var buildstamp = "2021-12-06_14:34:11" +var commits = "236" +var version = "456f174-b236 - 2021-12-06_14:34:11"