Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing the ways metrics are autogenerated #11

Merged
merged 1 commit into from
Jul 31, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def __repr__(self):

@property
def isnum(self):
return self.type in ('LONG', 'DOUBLE')
return self.type in ('LONG', 'DOUBLE', 'FLOAT')

def generate_metrics(self):
M = Metric
Expand All @@ -198,9 +198,11 @@ def generate_metrics(self):
metric_type='count',
json=json.dumps({'type': 'count', 'name': 'count'})
))
# Somehow we need to reassign this for UDAFs
corrected_type = 'DOUBLE' if self.type in ('DOUBLE', 'FLOAT') else 'self.type'

if self.sum and self.isnum:
mt = self.type.lower() + 'Sum'
mt = corrected_type.lower() + 'Sum'
name='sum__' + self.column_name
metrics.append(Metric(
metric_name=name,
Expand All @@ -210,7 +212,7 @@ def generate_metrics(self):
'type': mt, 'name': name, 'fieldName': self.column_name})
))
if self.min and self.isnum:
mt = self.type.lower() + 'Min'
mt = corrected_type.lower() + 'Min'
name='min__' + self.column_name
metrics.append(Metric(
metric_name=name,
Expand All @@ -220,7 +222,7 @@ def generate_metrics(self):
'type': mt, 'name': name, 'fieldName': self.column_name})
))
if self.max and self.isnum:
mt = self.type.lower() + 'Max'
mt = corrected_type.lower() + 'Max'
name='max__' + self.column_name
metrics.append(Metric(
metric_name=name,
Expand All @@ -245,8 +247,9 @@ def generate_metrics(self):
for metric in metrics:
m = (
session.query(M)
.filter(M.datasource_name==self.datasource_name)
.filter(M.metric_name==metric.metric_name)
.filter(M.datasource_name==self.datasource_name)
.filter(Cluster.cluster_name==self.datasource.cluster_name)
.first()
)
metric.datasource_name = self.datasource_name
Expand Down