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

fix: Removes unused cache cleanup #26648

Merged
merged 1 commit into from
Jan 17, 2024
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
4 changes: 0 additions & 4 deletions superset/commands/chart/delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
from superset.daos.exceptions import DAODeleteFailedError
from superset.daos.report import ReportScheduleDAO
from superset.exceptions import SupersetSecurityException
from superset.models.dashboard import Dashboard
from superset.models.slice import Slice

logger = logging.getLogger(__name__)
Expand All @@ -46,9 +45,6 @@ def run(self) -> None:
self.validate()
assert self._models

for model_id in self._model_ids:
Dashboard.clear_cache_for_slice(slice_id=model_id)

try:
ChartDAO.delete(self._models)
except DAODeleteFailedError as ex:
Expand Down
34 changes: 0 additions & 34 deletions superset/models/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,18 @@
from sqlalchemy.engine.base import Connection
from sqlalchemy.orm import relationship, sessionmaker, subqueryload
from sqlalchemy.orm.mapper import Mapper
from sqlalchemy.sql import join, select
from sqlalchemy.sql.elements import BinaryExpression

from superset import app, db, is_feature_enabled, security_manager
from superset.connectors.sqla.models import BaseDatasource, SqlaTable
from superset.daos.datasource import DatasourceDAO
from superset.extensions import cache_manager
from superset.models.helpers import AuditMixinNullable, ImportExportMixin
from superset.models.slice import Slice
from superset.models.user_attributes import UserAttribute
from superset.tasks.thumbnails import cache_dashboard_thumbnail
from superset.tasks.utils import get_current_user
from superset.thumbnails.digest import get_dashboard_digest
from superset.utils import core as utils
from superset.utils.decorators import debounce

metadata = Model.metadata # pylint: disable=no-member
config = app.config
Expand Down Expand Up @@ -137,7 +134,6 @@ def copy_dashboard(_mapper: Mapper, connection: Connection, target: Dashboard) -
)


# pylint: disable=too-many-public-methods
class Dashboard(AuditMixinNullable, ImportExportMixin, Model):
"""The dashboard object!"""

Expand Down Expand Up @@ -322,36 +318,6 @@ def update_thumbnail(self) -> None:
force=True,
)

@debounce(0.1)
def clear_cache(self) -> None:
cache_manager.cache.delete_memoized(Dashboard.datasets_trimmed_for_slices, self)

@classmethod
@debounce(0.1)
def clear_cache_for_slice(cls, slice_id: int) -> None:
filter_query = select([dashboard_slices.c.dashboard_id], distinct=True).where(
dashboard_slices.c.slice_id == slice_id
)
for (dashboard_id,) in db.engine.execute(filter_query):
cls(id=dashboard_id).clear_cache()

@classmethod
@debounce(0.1)
def clear_cache_for_datasource(cls, datasource_id: int) -> None:
filter_query = select(
[dashboard_slices.c.dashboard_id],
distinct=True,
).select_from(
join(
dashboard_slices,
Slice,
(Slice.id == dashboard_slices.c.slice_id)
& (Slice.datasource_id == datasource_id),
)
)
for (dashboard_id,) in db.engine.execute(filter_query):
cls(id=dashboard_id).clear_cache()

@classmethod
def export_dashboards( # pylint: disable=too-many-locals
cls,
Expand Down
Loading