mirror of
https://github.com/getredash/redash.git
synced 2025-12-25 01:03:20 -05:00
Prefetching for widgets/visualizations/queries/query resutls when getting dashboard.
This commit is contained in:
@@ -104,7 +104,6 @@ class DashboardListAPI(BaseResource):
|
||||
|
||||
class DashboardAPI(BaseResource):
|
||||
def get(self, dashboard_slug=None):
|
||||
# TODO: prefetching of widgets, visualizations and query results?
|
||||
try:
|
||||
dashboard = models.Dashboard.get_by_slug(dashboard_slug)
|
||||
except models.Dashboard.DoesNotExist:
|
||||
|
||||
@@ -145,7 +145,9 @@ class Dashboard(db.Model):
|
||||
layout = json.loads(self.layout)
|
||||
|
||||
if with_widgets:
|
||||
widgets = {w.id: w.to_dict() for w in self.widgets}
|
||||
widgets = Widget.select(Widget, Visualization, Query, QueryResult).\
|
||||
where(Widget.dashboard == self.id).join(Visualization).join(Query).join(QueryResult)
|
||||
widgets = {w.id: w.to_dict() for w in widgets}
|
||||
widgets_layout = map(lambda row: map(lambda widget_id: widgets.get(widget_id, None), row), layout)
|
||||
else:
|
||||
widgets_layout = None
|
||||
|
||||
Reference in New Issue
Block a user