From 2bb378b786ebaee097207e479892dce147f5b50a Mon Sep 17 00:00:00 2001 From: Tom Owers Date: Tue, 14 Nov 2023 14:06:47 +0000 Subject: [PATCH] fix(exports): breakdown limit (#18597) Use the breakdown limit in the query params for the next page if it exists --- posthog/api/insight.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/posthog/api/insight.py b/posthog/api/insight.py index 683d4895aca6e..a31f2dd9dbe05 100644 --- a/posthog/api/insight.py +++ b/posthog/api/insight.py @@ -819,9 +819,16 @@ def trend(self, request: request.Request, *args: Any, **kwargs: Any): except HogQLException as e: raise ValidationError(str(e)) filter = Filter(request=request, team=self.team) + + params_breakdown_limit = request.GET.get("breakdown_limit") + if params_breakdown_limit is not None and params_breakdown_limit != "": + breakdown_values_limit = int(params_breakdown_limit) + else: + breakdown_values_limit = BREAKDOWN_VALUES_LIMIT + next = ( - format_paginated_url(request, filter.offset, BREAKDOWN_VALUES_LIMIT) - if len(result["result"]) >= BREAKDOWN_VALUES_LIMIT + format_paginated_url(request, filter.offset, breakdown_values_limit) + if len(result["result"]) >= breakdown_values_limit else None ) if self.request.accepted_renderer.format == "csv":