You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2022/07/14 11:31:53 UTC

[GitHub] [superset] zhaoyongjie commented on a diff in pull request #20683: feat: the samples endpoint supports filters and pagination

zhaoyongjie commented on code in PR #20683:
URL: https://github.com/apache/superset/pull/20683#discussion_r921052780


##########
superset/datasets/commands/samples.py:
##########
@@ -78,3 +116,24 @@ def validate(self) -> None:
             security_manager.raise_for_ownership(self._model)
         except SupersetSecurityException as ex:
             raise DatasetForbiddenError() from ex
+
+    @staticmethod
+    def get_limit_clause(
+        page: Optional[int], per_page: Optional[int]
+    ) -> Dict[str, int]:
+        samples_row_limit = app.config.get("SAMPLES_ROW_LIMIT", 1000)
+        limit = samples_row_limit
+        offset = 0
+
+        if isinstance(page, int) and isinstance(per_page, int):
+            limit = int(per_page)
+            if limit < 0 or limit > samples_row_limit:
+                # reset limit value if input is invalid
+                limit = samples_row_limit

Review Comment:
   Can be easily refactored to raise and exceptions if needed



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org