Skip to content

Commit

Permalink
fix(backend): incorrect pagination when no data (#1499)
Browse files Browse the repository at this point in the history
- fix an edge condition where sessions overview api would set `previous`
value of pagination meta incorrectly to `true` when there are no
results.

fixes #1497

Signed-off-by: detj <[email protected]>
  • Loading branch information
detj authored Nov 7, 2024
1 parent 4927aa7 commit 389d22a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions backend/api/measure/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -497,15 +497,15 @@ func GetSessionsWithFilter(ctx context.Context, af *filter.AppFilter) (sessions

resultLen := len(sessions)

// handle pagination
// set pagination next & previous
// flags
if resultLen > af.Limit {
sessions = sessions[:resultLen-1]
next = true
if af.Offset >= af.Limit {
previous = true
}
} else if resultLen <= af.Limit {
next = false
} else if resultLen > 0 && resultLen <= af.Limit {
previous = true
}

Expand Down

0 comments on commit 389d22a

Please sign in to comment.