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

Db support #51

Merged
merged 2 commits into from
Feb 23, 2022
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions api/dbConnections/mysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ def fetchDataframe(params: str, sql: str, limit: bool = False):
)
if limit:
sql = limitSql(sql)

# passing chunksize here instead of LIMIT, takes longer
chunksize = None
dataframe = pd.read_sql(sql, conn, chunksize=chunksize)

Expand Down
78 changes: 78 additions & 0 deletions api/seeddata/searchCardTemplate.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,83 @@
"renderType": "line",
"connectionType": 1
}
},
{
"model": "cueSearch.searchCardTemplate",
"pk": 7,
"fields": {
"published": false,
"templateName": "Table of all data",
"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 }}) AS templatetable WHERE {% for orResults in groupedResultsForFilter %} {% for orResult in orResults %} {{ orResult.dimension }} = '{{ orResult.value }}' OR {% endfor %} True AND {% endfor %} True limit 500",
"renderType": "table",
"connectionType": 2
}
},
{
"model": "cueSearch.searchCardTemplate",
"pk": 8,
"fields": {
"published": false,
"templateName": "Split on Filter Dimension",
"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 }}) AS templatetable WHERE {% for orResults in groupedResultsForFilter %} {% for orResult in orResults %} {{ orResult.dimension }} = '{{ orResult.value }}' OR {% endfor %} True AND {% endfor %} True GROUP BY 1, 2 limit 500 +-; {% endfor %} {% endif %} {% endfor %}",
"renderType": "line",
"connectionType": 2
}
},
{
"model": "cueSearch.searchCardTemplate",
"pk": 9,
"fields": {
"published": false,
"templateName": "Metric Chart",
"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 }}) AS templatetable WHERE {% for orResults in groupedResultsForFilter %} {% for orResult in orResults %} {{ orResult.dimension }} = '{{ orResult.value }}' OR {% endfor %} True AND {% endfor %} True GROUP BY 1 limit 500 +-; {% endfor %}",
"renderType": "line",
"connectionType": 2
}
},
{
"model": "cueSearch.searchCardTemplate",
"pk": 10,
"fields": {
"published": false,
"templateName": "Table of all data",
"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 TOP 500 * FROM ({{ datasetSql|safe }}) templatetable WHERE {% for orResults in groupedResultsForFilter %} {% for orResult in orResults %} {{ orResult.dimension }} = '{{ orResult.value }}' OR {% endfor %} 1=1 AND {% endfor %} 1=1 ",
"renderType": "table",
"connectionType": 7
}
},
{
"model": "cueSearch.searchCardTemplate",
"pk": 11,
"fields": {
"published": false,
"templateName": "Split on Filter Dimension",
"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 TOP 500 {{ timestampColumn }}, {{ filterDim }}, SUM({{ metricName }}) as {{metricName}} FROM ({{ datasetSql|safe }}) templatetable WHERE {% for orResults in groupedResultsForFilter %} {% for orResult in orResults %} {{ orResult.dimension }} = '{{ orResult.value }}' OR {% endfor %} 1=1 AND {% endfor %} 1=1 GROUP BY {{ timestampColumn }}, {{ filterDim }} +-; {% endfor %} {% endif %} {% endfor %}",
"renderType": "line",
"connectionType": 7
}
},
{
"model": "cueSearch.searchCardTemplate",
"pk": 12,
"fields": {
"published": false,
"templateName": "Metric Chart",
"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 TOP 500 {{ timestampColumn }}, SUM({{ metric }}) as {{ metric }} FROM ({{ datasetSql|safe }}) templatetable WHERE {% for orResults in groupedResultsForFilter %} {% for orResult in orResults %} {{ orResult.dimension }} = '{{ orResult.value }}' OR {% endfor %} 1=1 AND {% endfor %} 1=1 GROUP BY {{ timestampColumn }} +-; {% endfor %}",
"renderType": "line",
"connectionType": 7
}
}
]