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 2020/09/24 02:40:54 UTC

[GitHub] [incubator-superset] nytai opened a new pull request #11031: feat(saved_queries): add custom api filter for all string & text fields

nytai opened a new pull request #11031:
URL: https://github.com/apache/incubator-superset/pull/11031


   ### SUMMARY
   <!--- Describe the change below, including rationale and design decisions -->
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   <!--- Skip this if not applicable -->
   N/A
   ### TEST PLAN
   <!--- What steps should be taken to verify the changes -->
   -CI, unit tests
   ### ADDITIONAL INFORMATION
   <!--- Check any relevant boxes with "x" -->
   <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
   - [ ] Has associated issue:
   - [ ] Changes UI
   - [ ] Requires DB Migration.
   - [ ] Confirm DB Migration upgrade and downgrade tested.
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   


----------------------------------------------------------------
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.

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


[GitHub] [incubator-superset] dpgaspar commented on a change in pull request #11031: feat(saved_queries): add custom api filter for all string & text fields

Posted by GitBox <gi...@apache.org>.
dpgaspar commented on a change in pull request #11031:
URL: https://github.com/apache/incubator-superset/pull/11031#discussion_r494138203



##########
File path: tests/queries/saved_queries/api_tests.py
##########
@@ -195,6 +198,95 @@ def test_get_list_filter_saved_query(self):
         data = json.loads(rv.data.decode("utf-8"))
         assert data["count"] == len(all_queries)
 
+    @pytest.mark.usefixtures("create_saved_queries")
+    def test_get_list_custom_filter_schema_saved_query(self):
+        """
+        Saved Query API: Test get list and custom filter (schema) saved query
+        """
+        self.login(username="admin")
+        admin = self.get_user("admin")
+
+        all_queries = (
+            db.session.query(SavedQuery)
+            .filter(SavedQuery.created_by == admin)
+            .filter(SavedQuery.schema.ilike("%2%"))
+            .all()
+        )
+        query_string = {
+            "filters": [{"col": "label", "opr": "all_text", "value": "schema2"}],
+        }
+        uri = f"api/v1/saved_query/?q={prison.dumps(query_string)}"
+        rv = self.get_assert_metric(uri, "get_list")
+        assert rv.status_code == 200
+        data = json.loads(rv.data.decode("utf-8"))
+        assert data["count"] == len(all_queries)
+
+    @pytest.mark.usefixtures("create_saved_queries")
+    def test_get_list_custom_filter_label_saved_query(self):
+        """
+        Saved Query API: Test get list and custom filter (label) saved query
+        """
+        self.login(username="admin")
+        admin = self.get_user("admin")
+        all_queries = (
+            db.session.query(SavedQuery)
+            .filter(SavedQuery.created_by == admin)
+            .filter(SavedQuery.label.ilike("%3%"))
+            .all()
+        )
+        query_string = {
+            "filters": [{"col": "label", "opr": "all_text", "value": "label3"}],
+        }
+        uri = f"api/v1/saved_query/?q={prison.dumps(query_string)}"
+        rv = self.get_assert_metric(uri, "get_list")
+        assert rv.status_code == 200
+        data = json.loads(rv.data.decode("utf-8"))
+        assert data["count"] == len(all_queries)
+
+    @pytest.mark.usefixtures("create_saved_queries")
+    def test_get_list_custom_filter_sql_saved_query(self):
+        """
+        Saved Query API: Test get list and custom filter (sql) saved query
+        """
+        self.login(username="admin")
+        admin = self.get_user("admin")
+        all_queries = (
+            db.session.query(SavedQuery)
+            .filter(SavedQuery.created_by == admin)
+            .filter(SavedQuery.sql.ilike("%table%"))
+            .all()
+        )
+        query_string = {
+            "filters": [{"col": "label", "opr": "all_text", "value": "table"}],
+        }
+        uri = f"api/v1/saved_query/?q={prison.dumps(query_string)}"
+        rv = self.get_assert_metric(uri, "get_list")
+        assert rv.status_code == 200
+        data = json.loads(rv.data.decode("utf-8"))
+        assert data["count"] == len(all_queries)
+
+    @pytest.mark.usefixtures("create_saved_queries")
+    def test_get_list_custom_filter_description_saved_query(self):
+        """
+        Saved Query API: Test get list and custom filter (desription) saved query

Review comment:
       nit: `Saved Query API: Test get list and custom filter (description) saved query`




----------------------------------------------------------------
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.

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


[GitHub] [incubator-superset] nytai merged pull request #11031: feat(saved_queries): add custom api filter for all string & text fields

Posted by GitBox <gi...@apache.org>.
nytai merged pull request #11031:
URL: https://github.com/apache/incubator-superset/pull/11031


   


----------------------------------------------------------------
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.

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


[GitHub] [incubator-superset] nytai merged pull request #11031: feat(saved_queries): add custom api filter for all string & text fields

Posted by GitBox <gi...@apache.org>.
nytai merged pull request #11031:
URL: https://github.com/apache/incubator-superset/pull/11031


   


----------------------------------------------------------------
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.

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


[GitHub] [incubator-superset] dpgaspar commented on a change in pull request #11031: feat(saved_queries): add custom api filter for all string & text fields

Posted by GitBox <gi...@apache.org>.
dpgaspar commented on a change in pull request #11031:
URL: https://github.com/apache/incubator-superset/pull/11031#discussion_r494138203



##########
File path: tests/queries/saved_queries/api_tests.py
##########
@@ -195,6 +198,95 @@ def test_get_list_filter_saved_query(self):
         data = json.loads(rv.data.decode("utf-8"))
         assert data["count"] == len(all_queries)
 
+    @pytest.mark.usefixtures("create_saved_queries")
+    def test_get_list_custom_filter_schema_saved_query(self):
+        """
+        Saved Query API: Test get list and custom filter (schema) saved query
+        """
+        self.login(username="admin")
+        admin = self.get_user("admin")
+
+        all_queries = (
+            db.session.query(SavedQuery)
+            .filter(SavedQuery.created_by == admin)
+            .filter(SavedQuery.schema.ilike("%2%"))
+            .all()
+        )
+        query_string = {
+            "filters": [{"col": "label", "opr": "all_text", "value": "schema2"}],
+        }
+        uri = f"api/v1/saved_query/?q={prison.dumps(query_string)}"
+        rv = self.get_assert_metric(uri, "get_list")
+        assert rv.status_code == 200
+        data = json.loads(rv.data.decode("utf-8"))
+        assert data["count"] == len(all_queries)
+
+    @pytest.mark.usefixtures("create_saved_queries")
+    def test_get_list_custom_filter_label_saved_query(self):
+        """
+        Saved Query API: Test get list and custom filter (label) saved query
+        """
+        self.login(username="admin")
+        admin = self.get_user("admin")
+        all_queries = (
+            db.session.query(SavedQuery)
+            .filter(SavedQuery.created_by == admin)
+            .filter(SavedQuery.label.ilike("%3%"))
+            .all()
+        )
+        query_string = {
+            "filters": [{"col": "label", "opr": "all_text", "value": "label3"}],
+        }
+        uri = f"api/v1/saved_query/?q={prison.dumps(query_string)}"
+        rv = self.get_assert_metric(uri, "get_list")
+        assert rv.status_code == 200
+        data = json.loads(rv.data.decode("utf-8"))
+        assert data["count"] == len(all_queries)
+
+    @pytest.mark.usefixtures("create_saved_queries")
+    def test_get_list_custom_filter_sql_saved_query(self):
+        """
+        Saved Query API: Test get list and custom filter (sql) saved query
+        """
+        self.login(username="admin")
+        admin = self.get_user("admin")
+        all_queries = (
+            db.session.query(SavedQuery)
+            .filter(SavedQuery.created_by == admin)
+            .filter(SavedQuery.sql.ilike("%table%"))
+            .all()
+        )
+        query_string = {
+            "filters": [{"col": "label", "opr": "all_text", "value": "table"}],
+        }
+        uri = f"api/v1/saved_query/?q={prison.dumps(query_string)}"
+        rv = self.get_assert_metric(uri, "get_list")
+        assert rv.status_code == 200
+        data = json.loads(rv.data.decode("utf-8"))
+        assert data["count"] == len(all_queries)
+
+    @pytest.mark.usefixtures("create_saved_queries")
+    def test_get_list_custom_filter_description_saved_query(self):
+        """
+        Saved Query API: Test get list and custom filter (desription) saved query

Review comment:
       nit: `Saved Query API: Test get list and custom filter (description) saved query`




----------------------------------------------------------------
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.

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