Skip to content

Commit

Permalink
Treat post aggregators as one kind of metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
x4base committed Apr 29, 2016
1 parent 0a56051 commit 152b47c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 13 deletions.
4 changes: 0 additions & 4 deletions caravel/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,6 @@ def __init__(self, viz):
'Metrics', choices=datasource.metrics_combo,
default=[default_metric],
description="One or many metrics to display"),
'post_aggregators': SelectMultipleSortableField(
'Post Aggregators', choices=datasource.post_aggregators_combo,
# default=[default_metric],
description=""),
'metric': SelectField(
'Metric', choices=datasource.metrics_combo,
default=default_metric,
Expand Down
12 changes: 5 additions & 7 deletions caravel/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,11 +536,6 @@ def metrics_combo(self):
for m in self.metrics],
key=lambda x: x[1])

@property
# TODO: Sqlable shouldn't have this for post aggregators are only for Druid
def post_aggregators_combo(self):
return []

@property
def sql_url(self):
return self.database.sql_url + "?table_name=" + str(self.table_name)
Expand Down Expand Up @@ -916,9 +911,11 @@ class DruidDatasource(Model, AuditMixinNullable, Queryable):

@property
def metrics_combo(self):
# Treat post aggregators as one kind of metrics
# TODO: Deal with name conflict between metrics and post_aggregators
return sorted(
[(m.metric_name, m.verbose_name) for m in self.metrics],
key=lambda x: x[1])
key=lambda x: x[1]) + self.post_aggregators_combo

@property
def post_aggregators_combo(self):
Expand Down Expand Up @@ -1088,9 +1085,10 @@ def query( # druid

query_str = ""

# TODO: Deal with name conflict between metrics and post_aggregators
post_aggregators = {
m.name: self.get_post_aggregator(m.json)
for m in self.post_aggregators if m.name in extras.get('post_aggregators')
for m in self.post_aggregators if m.name in metrics
}

metrics_dependencies = list(
Expand Down
2 changes: 0 additions & 2 deletions caravel/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ def query_obj(self):
'having': form_data.get("having", ''),
'time_grain_sqla': form_data.get("time_grain_sqla", ''),
'druid_time_origin': form_data.get("druid_time_origin", ''),
'post_aggregators': form_data.get("post_aggregators", ''),
}
d = {
'granularity': granularity,
Expand Down Expand Up @@ -332,7 +331,6 @@ class TableViz(BaseViz):
'fields': (
'groupby',
'metrics',
'post_aggregators',
)
}, {
'label': "NOT GROUPED BY",
Expand Down

0 comments on commit 152b47c

Please sign in to comment.