console: fix a possible divide by 0 error

This is not the only problem we have.
This commit is contained in:
Vincent Bernat
2022-07-09 08:06:23 +02:00
parent d70f59c70f
commit f5e2e85d0d
4 changed files with 28 additions and 28 deletions

View File

@@ -231,16 +231,16 @@ func TestWidgetGraph(t *testing.T) {
mockConn.EXPECT().
Select(gomock.Any(), gomock.Any(), `
SELECT
toStartOfInterval(TimeReceived, INTERVAL (intDiv(864, 1)*1) second) AS Time,
SUM(Bytes*SamplingRate*8/(intDiv(864, 1)*1))/1000/1000/1000 AS Gbps
toStartOfInterval(TimeReceived, INTERVAL max2(intDiv(864, 1)*1, 1) second) AS Time,
SUM(Bytes*SamplingRate*8/max2(intDiv(864, 1)*1, 1))/1000/1000/1000 AS Gbps
FROM flows
WHERE TimeReceived BETWEEN toDateTime('2009-11-10 23:00:00', 'UTC') AND toDateTime('2009-11-11 23:00:00', 'UTC')
AND InIfBoundary = 'external'
GROUP BY Time
ORDER BY Time WITH FILL
FROM toStartOfInterval(toDateTime('2009-11-10 23:00:00', 'UTC'), INTERVAL (intDiv(864, 1)*1) second)
FROM toStartOfInterval(toDateTime('2009-11-10 23:00:00', 'UTC'), INTERVAL max2(intDiv(864, 1)*1, 1) second)
TO toDateTime('2009-11-11 23:00:00', 'UTC')
STEP (intDiv(864, 1)*1)`).
STEP toUInt32(max2(intDiv(864, 1)*1, 1))`).
SetArg(1, expected).
Return(nil)