Skip to content
Closed
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
1 change: 1 addition & 0 deletions redash/settings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@

SCHEMAS_REFRESH_SCHEDULE = int(os.environ.get("REDASH_SCHEMAS_REFRESH_SCHEDULE", 30))
SCHEMAS_REFRESH_TIMEOUT = int(os.environ.get("REDASH_SCHEMAS_REFRESH_TIMEOUT", 300))
SCHEMAS_REFRESH_EXCLUDED_TYPES = set_from_string(os.environ.get("REDASH_SCHEMAS_REFRESH_EXCLUDED_TYPES", ""))

AUTH_TYPE = os.environ.get("REDASH_AUTH_TYPE", "api_key")
INVITATION_TOKEN_MAX_AGE = int(os.environ.get("REDASH_INVITATION_TOKEN_MAX_AGE", 60 * 60 * 24 * 7))
Expand Down
2 changes: 2 additions & 0 deletions redash/tasks/queries/maintenance.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@ def refresh_schemas():
)
elif ds.id in blacklist:
logger.info("task=refresh_schema state=skip ds_id=%s reason=blacklist", ds.id)
elif ds.type in settings.SCHEMAS_REFRESH_EXCLUDED_TYPES:
logger.info("task=refresh_schema state=skip ds_id=%s reason=type_excluded", ds.id)
elif ds.org.is_disabled:
logger.info("task=refresh_schema state=skip ds_id=%s reason=org_disabled", ds.id)
else:
Expand Down
9 changes: 9 additions & 0 deletions tests/tasks/test_refresh_schemas.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from mock import patch

from redash import settings
from redash.tasks import refresh_schemas
from tests import BaseTestCase

Expand All @@ -23,3 +24,11 @@ def test_skips_paused_data_sources(self):
with patch("redash.tasks.queries.maintenance.refresh_schema.delay") as refresh_job:
refresh_schemas()
refresh_job.assert_called()

def test_skips_excluded_datasource_types(self):
ds = self.factory.data_source

with patch.object(settings, "SCHEMAS_REFRESH_EXCLUDED_TYPES", {ds.type}):
with patch("redash.tasks.queries.maintenance.refresh_schema.delay") as refresh_job:
refresh_schemas()
refresh_job.assert_not_called()
Loading