From 2804ee0e34f1b010db1732fa50551eab4b137f7b Mon Sep 17 00:00:00 2001 From: Lukas Biermann Date: Mon, 24 Jun 2024 09:48:23 +0200 Subject: [PATCH 1/4] fix: change tag get objects method to be aligned with api documentation --- superset/tags/api.py | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/superset/tags/api.py b/superset/tags/api.py index ad25ffe7c936d..e3aa9624de7de 100644 --- a/superset/tags/api.py +++ b/superset/tags/api.py @@ -546,7 +546,7 @@ def bulk_delete(self, **kwargs: Any) -> Response: except TagDeleteFailedError as ex: return self.response_422(message=str(ex)) - @expose("/get_objects/", methods=("GET",)) + @expose("/get_objects/", methods=("GET",)) @protect() @safe @statsd_metrics @@ -554,7 +554,7 @@ def bulk_delete(self, **kwargs: Any) -> Response: action=lambda self, *args, **kwargs: f"{self.__class__.__name__}.get_objects", log_to_statsd=False, ) - def get_objects(self) -> Response: + def get_objects(self, tag_id: int) -> Response: """Get all objects associated with a tag. --- get: @@ -587,21 +587,9 @@ def get_objects(self) -> Response: 500: $ref: '#/components/responses/500' """ - tag_ids = [ - tag_id for tag_id in request.args.get("tagIds", "").split(",") if tag_id - ] - tags = [tag for tag in request.args.get("tags", "").split(",") if tag] - # filter types - types = [type_ for type_ in request.args.get("types", "").split(",") if type_] try: - if tag_ids: - # priotize using ids for lookups vs. names mainly using this - # for backward compatibility - tagged_objects = TagDAO.get_tagged_objects_by_tag_id(tag_ids, types) - else: - tagged_objects = TagDAO.get_tagged_objects_for_tags(tags, types) - + tagged_objects = TagDAO.get_tagged_objects_by_tag_id([tag_id]) result = [ self.object_entity_response_schema.dump(tagged_object) for tagged_object in tagged_objects From 3d2a2c5733853a5117f89639aa416c2c81f2a102 Mon Sep 17 00:00:00 2001 From: Lukas Biermann Date: Mon, 24 Jun 2024 22:25:19 +0200 Subject: [PATCH 2/4] Revert "fix: change tag get objects method to be aligned with api documentation" This reverts commit 2804ee0e34f1b010db1732fa50551eab4b137f7b. --- superset/tags/api.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/superset/tags/api.py b/superset/tags/api.py index e3aa9624de7de..ad25ffe7c936d 100644 --- a/superset/tags/api.py +++ b/superset/tags/api.py @@ -546,7 +546,7 @@ def bulk_delete(self, **kwargs: Any) -> Response: except TagDeleteFailedError as ex: return self.response_422(message=str(ex)) - @expose("/get_objects/", methods=("GET",)) + @expose("/get_objects/", methods=("GET",)) @protect() @safe @statsd_metrics @@ -554,7 +554,7 @@ def bulk_delete(self, **kwargs: Any) -> Response: action=lambda self, *args, **kwargs: f"{self.__class__.__name__}.get_objects", log_to_statsd=False, ) - def get_objects(self, tag_id: int) -> Response: + def get_objects(self) -> Response: """Get all objects associated with a tag. --- get: @@ -587,9 +587,21 @@ def get_objects(self, tag_id: int) -> Response: 500: $ref: '#/components/responses/500' """ + tag_ids = [ + tag_id for tag_id in request.args.get("tagIds", "").split(",") if tag_id + ] + tags = [tag for tag in request.args.get("tags", "").split(",") if tag] + # filter types + types = [type_ for type_ in request.args.get("types", "").split(",") if type_] try: - tagged_objects = TagDAO.get_tagged_objects_by_tag_id([tag_id]) + if tag_ids: + # priotize using ids for lookups vs. names mainly using this + # for backward compatibility + tagged_objects = TagDAO.get_tagged_objects_by_tag_id(tag_ids, types) + else: + tagged_objects = TagDAO.get_tagged_objects_for_tags(tags, types) + result = [ self.object_entity_response_schema.dump(tagged_object) for tagged_object in tagged_objects From 09d3056dac7b26ab4a798152a90da798b2d02c85 Mon Sep 17 00:00:00 2001 From: Lukas Biermann Date: Mon, 24 Jun 2024 23:15:24 +0200 Subject: [PATCH 3/4] fix: updated documentation for tags/get_objects to be in line with actual api implementation --- superset/tags/api.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/superset/tags/api.py b/superset/tags/api.py index ad25ffe7c936d..c710feacea472 100644 --- a/superset/tags/api.py +++ b/superset/tags/api.py @@ -558,12 +558,28 @@ def get_objects(self) -> Response: """Get all objects associated with a tag. --- get: - summary: Get all objects associated with a tag + summary: Get all objects associated with a tag. If tagIds is set tags will be ignored. parameters: - in: path + name: tagIds schema: - type: integer - name: tag_id + type: array + items: + type: integer + - in: path + name: tags + schema: + type: array + items: + type: string + - in: path + name: types + schema: + type: array + schema: + items: + type: string + responses: 200: description: List of tagged objects associated with a Tag From 3731b6e624bd46ce5b9e9687169ab992eb4900b7 Mon Sep 17 00:00:00 2001 From: Lukas Biermann Date: Tue, 25 Jun 2024 08:52:17 +0200 Subject: [PATCH 4/4] removed wrong schema command --- superset/tags/api.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/superset/tags/api.py b/superset/tags/api.py index c710feacea472..1ed02f319cb6a 100644 --- a/superset/tags/api.py +++ b/superset/tags/api.py @@ -576,9 +576,8 @@ def get_objects(self) -> Response: name: types schema: type: array - schema: - items: - type: string + items: + type: string responses: 200: