Merge pull request #4602 from john-bodley/john-bodley-druid-sync-fix-filter

[druid] Adding cluster filter for refresh
This commit is contained in:
John Bodley 2018-03-13 10:53:36 -07:00 committed by GitHub
commit 037c04102f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -157,16 +157,15 @@ class DruidCluster(Model, AuditMixinNullable, ImportMixin):
def refresh(self, datasource_names, merge_flag, refreshAll): def refresh(self, datasource_names, merge_flag, refreshAll):
""" """
Fetches metadata for the specified datasources andm Fetches metadata for the specified datasources and
merges to the Superset database merges to the Superset database
""" """
session = db.session session = db.session
ds_list = ( ds_list = (
session.query(DruidDatasource) session.query(DruidDatasource)
.filter(or_(DruidDatasource.datasource_name == name .filter(DruidDatasource.cluster_name == self.cluster_name)
for name in datasource_names)) .filter(DruidDatasource.datasource_name.in_(datasource_names))
) )
ds_map = {ds.name: ds for ds in ds_list} ds_map = {ds.name: ds for ds in ds_list}
for ds_name in datasource_names: for ds_name in datasource_names:
datasource = ds_map.get(ds_name, None) datasource = ds_map.get(ds_name, None)