From 7861fea134e36fef7b0d40d473168296fc84a168 Mon Sep 17 00:00:00 2001 From: detj Date: Thu, 7 Nov 2024 10:17:19 +0530 Subject: [PATCH] fix(backend): incorrect pagination when no data - 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 }