craig-rueda commented on a change in pull request #9329: [WiP] [charts] 
Refactor API using SIP-35
URL: 
https://github.com/apache/incubator-superset/pull/9329#discussion_r395165307
 
 

 ##########
 File path: superset/charts/dao.py
 ##########
 @@ -0,0 +1,47 @@
+# 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.
+import logging
+from typing import Dict, List, Optional
+
+from superset.charts.filters import ChartFilter
+from superset.dao.base import BaseDAO
+from superset.extensions import db
+from superset.models.dashboard import Dashboard
+from superset.models.slice import Slice
+
+logger = logging.getLogger(__name__)
+
+
+class ChartDAO(BaseDAO):
+    model_cls = Slice
+    base_filter = ChartFilter
+
+    @staticmethod
+    def get_dashboards_by_ids(dashboard_ids: List[int]) -> List[Dashboard]:
+        return 
db.session.query(Dashboard).filter(Dashboard.id.in_(dashboard_ids)).all()
+
+    @classmethod
+    def create(cls, properties: Dict, commit=True) -> Optional[Slice]:
 
 Review comment:
   This is a bit confusing, as a ChartDAO should simply CRUD on Slices. We 
shouldn't need, or want, to pass in a model class for each invocation. The 
ChartDAO should already know what its model class is (as I see you have 
declared in the class prop)

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

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

Reply via email to