From 389d22af466a89be7fd59d2e7ff36ed89cb81409 Mon Sep 17 00:00:00 2001 From: Debjeet Biswas Date: Thu, 7 Nov 2024 11:41:22 +0530 Subject: [PATCH] fix(backend): incorrect pagination when no data (#1499) - 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 --- backend/api/measure/session.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/backend/api/measure/session.go b/backend/api/measure/session.go index ea0c6e63e..99d4f4ebf 100644 --- a/backend/api/measure/session.go +++ b/backend/api/measure/session.go @@ -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 }