Skip to content

Commit

Permalink
Adding Metric class as well
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch committed Feb 10, 2016
1 parent b18d117 commit 32442aa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
12 changes: 6 additions & 6 deletions panoramix/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1050,7 +1050,7 @@ class Log(Model):
dttm = Column(DateTime, default=func.now())


class Metric(Model):
class DruidMetric(Model):
__tablename__ = 'metrics'
id = Column(Integer, primary_key=True)
metric_name = Column(String(512))
Expand Down Expand Up @@ -1098,9 +1098,9 @@ def isnum(self):
return self.type in ('LONG', 'DOUBLE', 'FLOAT')

def generate_metrics(self):
M = Metric
M = DruidMetric
metrics = []
metrics.append(Metric(
metrics.append(DruidMetric(
metric_name='count',
verbose_name='COUNT(*)',
metric_type='count',
Expand All @@ -1125,7 +1125,7 @@ def generate_metrics(self):
if self.min and self.isnum:
mt = corrected_type.lower() + 'Min'
name = 'min__' + self.column_name
metrics.append(Metric(
metrics.append(DruidMetric(
metric_name=name,
metric_type='min',
verbose_name='MIN({})'.format(self.column_name),
Expand All @@ -1135,7 +1135,7 @@ def generate_metrics(self):
if self.max and self.isnum:
mt = corrected_type.lower() + 'Max'
name = 'max__' + self.column_name
metrics.append(Metric(
metrics.append(DruidMetric(
metric_name=name,
metric_type='max',
verbose_name='MAX({})'.format(self.column_name),
Expand All @@ -1145,7 +1145,7 @@ def generate_metrics(self):
if self.count_distinct:
mt = 'count_distinct'
name = 'count_distinct__' + self.column_name
metrics.append(Metric(
metrics.append(DruidMetric(
metric_name=name,
verbose_name='COUNT(DISTINCT {})'.format(self.column_name),
metric_type='count_distinct',
Expand Down
10 changes: 5 additions & 5 deletions panoramix/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class DruidColumnInlineView(CompactCRUDMixin, PanoramixModelView):
def post_update(self, col):
col.generate_metrics()

appbuilder.add_view_no_menu(ColumnInlineView)
appbuilder.add_view_no_menu(DruidColumnInlineView)


class SqlMetricInlineView(CompactCRUDMixin, PanoramixModelView):
Expand All @@ -99,8 +99,8 @@ class SqlMetricInlineView(CompactCRUDMixin, PanoramixModelView):
appbuilder.add_view_no_menu(SqlMetricInlineView)


class MetricInlineView(CompactCRUDMixin, PanoramixModelView):
datamodel = SQLAInterface(models.Metric)
class DruidMetricInlineView(CompactCRUDMixin, PanoramixModelView):
datamodel = SQLAInterface(models.DruidMetric)
list_columns = ['metric_name', 'verbose_name', 'metric_type']
edit_columns = [
'metric_name', 'description', 'verbose_name', 'metric_type',
Expand All @@ -111,7 +111,7 @@ class MetricInlineView(CompactCRUDMixin, PanoramixModelView):
validators_columns = {
'json': [validate_json],
}
appbuilder.add_view_no_menu(MetricInlineView)
appbuilder.add_view_no_menu(DruidMetricInlineView)


class DatabaseView(PanoramixModelView, DeleteMixin):
Expand Down Expand Up @@ -284,7 +284,7 @@ class DruidDatasourceModelView(PanoramixModelView, DeleteMixin):
'created_by', 'created_on',
'changed_by_', 'changed_on',
'offset']
related_views = [DruidColumnInlineView, MetricInlineView]
related_views = [DruidColumnInlineView, DruidMetricInlineView]
edit_columns = [
'datasource_name', 'cluster', 'description', 'owner',
'is_featured', 'is_hidden', 'default_endpoint', 'offset']
Expand Down

0 comments on commit 32442aa

Please sign in to comment.