Skip to content

Commit

Permalink
spread the cache love
Browse files Browse the repository at this point in the history
  • Loading branch information
suddjian committed Apr 23, 2021
1 parent d3d1584 commit ef322a3
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions superset/models/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,19 +164,19 @@ def __repr__(self) -> str:
@property
def table_names(self) -> str:
# pylint: disable=no-member
return ", ".join(str(s.datasource.full_name) for s in self.slices)
return ", ".join(str(s.datasource.full_name) for s in self.slices_cached())

@property
def url(self) -> str:
return f"/superset/dashboard/{self.slug or self.id}/"

@property
def datasources(self) -> Set[BaseDatasource]:
return {slc.datasource for slc in self.slices}
return {slc.datasource for slc in self.slices_cached()}

@property
def charts(self) -> List[BaseDatasource]:
return [slc.chart for slc in self.slices]
return [slc.chart for slc in self.slices_cached()]

@property
def sqla_metadata(self) -> None:
Expand Down Expand Up @@ -235,7 +235,7 @@ def data(self) -> Dict[str, Any]:
"dashboard_title": self.dashboard_title,
"published": self.published,
"slug": self.slug,
"slices": [slc.data for slc in self.slices],
"slices": [slc.data for slc in self.slices_cached()],
"position_json": positions,
"last_modified_time": self.changed_on.replace(microsecond=0).timestamp(),
}
Expand All @@ -254,7 +254,7 @@ def slices_cached(self) -> List[Slice]:
unless=lambda: not is_feature_enabled("DASHBOARD_CACHE"),
)
def datasets_trimmed_for_slices(self) -> Dict[str, Any]:
datasource_slices = utils.indexed(self.slices, "datasource")
datasource_slices = utils.indexed(self.slices_cached(), "datasource")
return {
# Filter out unneeded fields from the datasource payload
datasource.uid: datasource.data_for_slices(slices)
Expand Down

0 comments on commit ef322a3

Please sign in to comment.