revert order by change
All checks were successful
Go / build (1.21) (push) Successful in 1m8s
Go / build (1.22) (push) Successful in 1m7s

This commit is contained in:
saji 2024-03-08 09:40:54 -06:00
parent e9d40ce466
commit fe4cdfa0a4
2 changed files with 4 additions and 3 deletions

4
db.go
View file

@ -187,7 +187,7 @@ func (tdb *TelemDb) GetPackets(ctx context.Context, filter BusEventFilter, lim *
sb.WriteString(strings.Join(whereFrags, " AND "))
}
sb.WriteString(" ORDER BY ts ASC")
sb.WriteString(" ORDER BY ts DESC")
// Augment our data further if there's i.e a limit modifier.
// TODO: factor this out maybe?
@ -270,7 +270,7 @@ func (tdb *TelemDb) GetValues(ctx context.Context, filter BusEventFilter,
// join qstrings with AND
sb.WriteString(strings.Join(whereFrags, " AND "))
sb.WriteString(" ORDER BY ts ASC")
sb.WriteString(" ORDER BY ts DESC")
if lim != nil {
lim.ModifyStatement(&sb)

View file

@ -203,9 +203,10 @@ func Test_ApiV1GetPackets(t *testing.T) {
t.Fatalf("response length did not match, want %d got %d", len(tt.expectedResults), len(resultEvents))
}
// Note, the results are flipped here. We return earliest first.
for idx := range tt.expectedResults {
expected := tt.expectedResults[idx]
actual := resultEvents[idx]
actual := resultEvents[len(resultEvents) - 1 - idx]
if !expected.Equals(&actual) {
t.Errorf("packet did not match, want %v got %v", expected, actual)
}