From 8266356074ef48d9cf7055ffbd08dbafba4a31e1 Mon Sep 17 00:00:00 2001 From: Saqib Ansari Date: Tue, 31 Mar 2026 17:07:59 +0530 Subject: [PATCH] fix: update max page_size (#1020) (cherry picked from commit 3eef8111cf614ca879e992d446d797aef026315d) # Conflicts: # insights/insights/doctype/insights_data_source_v3/ibis_utils.py --- .../insights_data_source_v3/ibis_utils.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/insights/insights/doctype/insights_data_source_v3/ibis_utils.py b/insights/insights/doctype/insights_data_source_v3/ibis_utils.py index 3eb0085e5..b0c875497 100644 --- a/insights/insights/doctype/insights_data_source_v3/ibis_utils.py +++ b/insights/insights/doctype/insights_data_source_v3/ibis_utils.py @@ -740,6 +740,16 @@ def get_current_columns(self): return {col: getattr(self.query, col) for col in self.query.schema().names} +<<<<<<< HEAD +======= +def clamp(value, lo: int, hi: int) -> int: + try: + return max(lo, min(int(value), hi)) + except (TypeError, ValueError): + return lo + + +>>>>>>> 3eef8111 (fix: update max page_size (#1020)) def execute_ibis_query( query: IbisQuery, limit=100, @@ -749,6 +759,15 @@ def execute_ibis_query( reference_doctype=None, reference_name=None, ): +<<<<<<< HEAD +======= + if hasattr(query, "limit"): + page_size = clamp(page_size, 1, 10_000) + page = clamp(page, 1, 10_000) + offset = (page - 1) * page_size + query = query.limit(page_size, offset=offset) + +>>>>>>> 3eef8111 (fix: update max page_size (#1020)) try: sql = ibis.to_sql(query) except ibis.common.exceptions.OperationNotDefinedError: