Mogball commented on a change in pull request #4655: [druid] Updating refresh
logic
URL:
https://github.com/apache/incubator-superset/pull/4655#discussion_r176303383
##########
File path: superset/connectors/druid/models.py
##########
@@ -653,24 +657,9 @@ def latest_metadata(self):
if segment_metadata:
return segment_metadata[-1]['columns']
- def generate_metrics(self):
- self.generate_metrics_for(self.columns)
-
- def generate_metrics_for(self, columns):
- metrics = {}
- for col in columns:
- metrics.update(col.get_metrics())
- dbmetrics = (
- db.session.query(DruidMetric)
- .filter(DruidMetric.datasource_id == self.id)
- .filter(or_(DruidMetric.metric_name == m for m in metrics))
- )
- dbmetrics = {metric.metric_name: metric for metric in dbmetrics}
- for metric in metrics.values():
- metric.datasource_id = self.id
- if not dbmetrics.get(metric.metric_name, None):
- with db.session.no_autoflush:
- db.session.add(metric)
+ def refresh_metrics(self):
+ for col in self.columns:
Review comment:
I mean the same could apply here as well, where it's possible to combine all
of the columns' metrics into one query
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services