Skip to content

Commit

Permalink
run the query if it doesn't have latest_query_data (re getredash#166)
Browse files Browse the repository at this point in the history
  • Loading branch information
alison985 authored and Allen Short committed Dec 12, 2017
1 parent 1166a9e commit 5cf1a4f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion redash/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def public_widget(widget):
'updated_at': widget.visualization.updated_at,
'created_at': widget.visualization.created_at,
'query': {
'id': widget.visualization.query_rel.id,
'query': ' ', # workaround, as otherwise the query data won't be loaded.
'name': widget.visualization.query_rel.name,
'description': widget.visualization.query_rel.description,
Expand All @@ -45,9 +46,16 @@ def public_dashboard(dashboard):
widget_list = (models.Widget.query
.filter(models.Widget.dashboard_id == dashboard.id)
.outerjoin(models.Visualization)
.outerjoin(models.Query))
.outerjoin(models.Query)
)

widgets = {w.id: public_widget(w) for w in widget_list}

# make sure all widgets' query's have a last_query_data_id that is not null so public dashboards work
for w in widgets:
if not hasattr(w, 'latest_query_data'):
models.Query.query.filter(models.Query.id == widgets[w]['visualization']['query']['id']).first()

widgets_layout = []
for row in dashboard_dict['layout']:
new_row = []
Expand Down

0 comments on commit 5cf1a4f

Please sign in to comment.