zhaoyongjie commented on a change in pull request #17335: URL: https://github.com/apache/superset/pull/17335#discussion_r748381837
########## File path: superset/migrations/versions/f9847149153d_add_certifications_columns_to_slice.py ########## @@ -0,0 +1,37 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +"""add_certifications_columns_to_slice + +Revision ID: f9847149153d +Revises: b92d69a6643c +Create Date: 2021-11-03 14:07:09.905194 + +""" + +# revision identifiers, used by Alembic. +import sqlalchemy as sa +from alembic import op + +revision = "f9847149153d" +down_revision = "b92d69a6643c" + + +def upgrade(): + op.add_column("slices", sa.Column("certified_by", sa.Text(), nullable=True)) + op.add_column( + "slices", sa.Column("certification_details", sa.Text(), nullable=True) + ) Review comment: we should provide `def downgrade()` function in migration script. follow [SIP-59](https://github.com/apache/superset/issues/13351) ########## File path: superset/charts/filters.py ########## @@ -55,6 +55,22 @@ class ChartFavoriteFilter(BaseFavoriteFilter): # pylint: disable=too-few-public model = Slice +class ChartCertifiedFilter(BaseFilter): # pylint: disable=too-few-public-methods + """ + Custom filter for the GET list that filters all certified charts + """ + + name = _("Is certified") + arg_name = "chart_is_certified" + + def apply(self, query: Query, value: Any) -> Query: + if value is True: + return query.filter(and_(Slice.certified_by.isnot(None))) + if value is False: + return query.filter(and_(Slice.certified_by.is_(None))) + return query Review comment: ```suggestion if value: return query.filter(and_(Slice.certified_by.isnot(None), certified_by == True)) return query ``` ########## File path: superset/dashboards/filters.py ########## @@ -158,3 +158,19 @@ def apply(self, query: Query, value: Optional[Any]) -> Query: if value: return query.filter(role_model.name.ilike(f"%{value}%"),) return query + + +class DashboardCertifiedFilter(BaseFilter): # pylint: disable=too-few-public-methods + """ + Custom filter for the GET list that filters all certified dashboards + """ + + name = _("Is certified") + arg_name = "dashboard_is_certified" + + def apply(self, query: Query, value: Any) -> Query: + if value is True: + return query.filter(and_(Dashboard.certified_by.isnot(None),)) + if value is False: + return query.filter(and_(Dashboard.certified_by.is_(None),)) + return query Review comment: ```suggestion def apply(self, query: Query, value: Any) -> Query: if value: return query.filter(and_(Dashboard.certified_by.isnot(None), Dashboard.certified_by == True)) return 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. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
