Skip to content

Commit

Permalink
Merge pull request #44 from cuebook/template
Browse files Browse the repository at this point in the history
ConnectionType added in searchCardTemplate model
  • Loading branch information
vincue authored Feb 18, 2022
2 parents 08b9d9f + 1ff388e commit 4ab7d6c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
20 changes: 20 additions & 0 deletions api/cueSearch/migrations/0005_searchcardtemplate_connectiontype.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Generated by Django 3.2.5 on 2022-02-18 08:20

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('dataset', '0001_initial'),
('cueSearch', '0004_auto_20220217_0217'),
]

operations = [
migrations.AddField(
model_name='searchcardtemplate',
name='connectionType',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='dataset.connectiontype'),
),
]
6 changes: 4 additions & 2 deletions api/cueSearch/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.db import models
from dataset.models import Dataset
from dataset.models import Dataset, ConnectionType

# Create your models here.

Expand All @@ -26,7 +26,9 @@ def __str__(self):
class SearchCardTemplate(models.Model):
RENDER_TYPE_TABLE = "table"
RENDER_TYPE_LINE = "line"

connectionType = models.ForeignKey(
ConnectionType, on_delete=models.SET_NULL, null=True, blank=True
)
templateName = models.TextField(null=True, blank=True)
title = models.TextField(null=True, blank=True)
bodyText = models.TextField(null=True, blank=True)
Expand Down
9 changes: 6 additions & 3 deletions api/seeddata/searchCardTemplate.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"title": "Dataset = <span style=\"background:#eee; padding: 0 4px; border-radius: 4px;\">{{dataset}}</span> where <span style=\"background:#eee; padding: 0 4px; border-radius: 4px;\">{{filter}}</span>",
"bodyText": "This table displays raw data for dataset <span style=\"background:#eee; padding: 0 4px; border-radius: 4px;\">{{dataset}}</span> with filter <span style=\"background:#eee; padding: 0 4px; border-radius: 4px;\">{{filter}}</span> ",
"sql": "SELECT * FROM ({{ datasetSql|safe }}) WHERE {{filter|safe}} limit 500",
"renderType": "table"
"renderType": "table",
"connectionType": 6
}
},
{
Expand All @@ -20,7 +21,8 @@
"title": "{% load event_tags %} {% for filterDim in filterDimensions %} {% conditionalCount searchResults 'dimension' filterDim as dimCount %} {% if dimCount > 1 %} {% for metricName in metrics %} Comparison of <span style=\"background:#eee; padding: 0 4px; border-radius: 4px;\">{{metricName}}</span> among <span style=\"background:#eee; padding: 0 4px; border-radius: 4px;\">{{filterDim}}</span> values in <span style=\"background:#eee; padding: 0 4px; border-radius: 4px;\">{{dataset}}</span> +-; {% endfor %} {% endif %} {% endfor %}",
"bodyText": "{% load event_tags %} {% for filterDim in filterDimensions %} {% conditionalCount searchResults 'dimension' filterDim as dimCount %} {% if dimCount > 1 %} {% for metricName in metrics %} This chart displays filtered values on dimension <span style=\"background:#eee; padding: 0 4px; border-radius: 4px;\">{{filterDim}}</span> along with other filters applied i.e. <span style=\"background:#eee; padding: 0 4px; border-radius: 4px;\">{{filter|safe}}</span> for metric <span style=\"background:#eee; padding: 0 4px; border-radius: 4px;\">{{metricName}}</span> on dataset <span style=\"background:#eee; padding: 0 4px; border-radius: 4px;\">{{dataset}}</span> +-; {% endfor %} {% endif %} {% endfor %}",
"sql": "{% load event_tags %} {% for filterDim in filterDimensions %} {% conditionalCount searchResults 'dimension' filterDim as dimCount %} {% if dimCount > 1 %} {% for metricName in metrics %} SELECT ({{ timestampColumn }}), {{ filterDim }}, SUM({{ metricName }}) as {{metricName}} FROM ({{ datasetSql|safe }}) WHERE {{filter|safe}} GROUP BY 1, 2 limit 500 +-; {% endfor %} {% endif %} {% endfor %}",
"renderType": "line"
"renderType": "line",
"connectionType": 6
}
},
{
Expand All @@ -32,7 +34,8 @@
"title": " {% for metric in metrics %} <span style=\"background:#eee; padding: 0 4px; border-radius: 4px;\"> {{ metric }}</span> from <span style=\"background:#eee; padding: 0 4px; border-radius: 4px;\">{{dataset}}</span> where <span style=\"background:#eee; padding: 0 4px; border-radius: 4px;\">{{filter}}</span> +-; {% endfor %}",
"bodyText": " {% for metric in metrics %} For <span style=\"background:#eee; padding: 0 4px; border-radius: 4px;\">{{filter}}</span> +-; {% endfor %}",
"sql": " {% for metric in metrics %} SELECT ({{ timestampColumn }}), SUM({{ metric }}) as {{ metric }} FROM ({{ datasetSql|safe }}) WHERE {{filter|safe}} GROUP BY 1 limit 500 +-; {% endfor %}",
"renderType": "line"
"renderType": "line",
"connectionType": 6
}
}
]

0 comments on commit 4ab7d6c

Please sign in to comment.