Skip to content

Commit

Permalink
fix: event ordering when more than 1000 events logged (#538)
Browse files Browse the repository at this point in the history
Fixes #490
  • Loading branch information
wesbillman authored Nov 2, 2023
1 parent 6584788 commit c271506
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions backend/controller/internal/dal/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,10 @@ func (d *DAL) QueryEvents(ctx context.Context, limit int, filters ...EventFilter
return index - 1
}
if !filter.olderThan.IsZero() {
q += fmt.Sprintf(" AND time_stamp <= $%d::TIMESTAMPTZ", param(filter.olderThan))
q += fmt.Sprintf(" AND e.time_stamp <= $%d::TIMESTAMPTZ", param(filter.olderThan))
}
if !filter.newerThan.IsZero() {
q += fmt.Sprintf(" AND time_stamp >= $%d::TIMESTAMPTZ", param(filter.newerThan))
q += fmt.Sprintf(" AND e.time_stamp >= $%d::TIMESTAMPTZ", param(filter.newerThan))
}
if filter.idHigherThan != 0 {
q += fmt.Sprintf(" AND e.id >= $%d::BIGINT", param(filter.idHigherThan))
Expand Down Expand Up @@ -279,9 +279,9 @@ func (d *DAL) QueryEvents(ctx context.Context, limit int, filters ...EventFilter
}

if filter.descending {
q += " ORDER BY time_stamp DESC"
q += " ORDER BY e.time_stamp DESC, e.id DESC"
} else {
q += " ORDER BY time_stamp ASC"
q += " ORDER BY e.time_stamp ASC, e.id ASC"
}

q += fmt.Sprintf(" LIMIT %d", limit)
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/services/console.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,14 @@ export const streamEvents = async ({
try {
let events: Event[] = []
for await (const response of client.streamEvents(
{ updateInterval: { seconds: BigInt(1) }, query: { limit: 1000, filters } },
{ updateInterval: { seconds: BigInt(1) }, query: { limit: 1000, filters, order: EventsQuery_Order.DESC } },
{ signal: abortControllerSignal },
)) {
if (response.event != null) {
events.push(response.event)
}
if (!response.more) {
onEventsReceived(events.reverse())
onEventsReceived(events)
events = []
}
}
Expand Down

0 comments on commit c271506

Please sign in to comment.