Skip to content

Commit

Permalink
configure skipping data change for domains
Browse files Browse the repository at this point in the history
  • Loading branch information
mkangia committed Dec 19, 2024
1 parent e184d8b commit b322aab
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
14 changes: 14 additions & 0 deletions hq_superset/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
)
from cryptography.fernet import MultiFernet
from superset import db
from superset_config import SKIP_DATASET_CHANGE_FOR_DOMAINS

from hq_superset.const import OAUTH2_DATABASE_NAME
from hq_superset.exceptions import TableMissing
Expand All @@ -16,6 +17,15 @@
get_hq_database,
)

import logging
logger = logging.getLogger(__name__)

# constant here instead of const due to
# circular import error with config in const
SKIP_DATASET_CHANGE_FOR_SCHEMAS = [
f"hqdomain_{domain_name}"
for domain_name in SKIP_DATASET_CHANGE_FOR_DOMAINS
]

@dataclass
class DataSetChange:
Expand All @@ -41,6 +51,10 @@ def update_dataset(self):
raise TableMissing(f'{self.data_source_id} table not found.')
table = sqla_table.get_sqla_table_object()

if table.schema and table.schema in SKIP_DATASET_CHANGE_FOR_SCHEMAS:
logger.info("Skipped change for schema {0}".format(table.schema))
return

with (
database.get_sqla_engine_with_context() as engine,
engine.connect() as connection,
Expand Down
1 change: 1 addition & 0 deletions hq_superset/tests/config_for_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,4 @@
FLASK_APP_MUTATOR = flask_app_mutator
CUSTOM_SECURITY_MANAGER = oauth.CommCareSecurityManager
USER_DOMAIN_ROLE_EXPIRY = 60 # minutes
SKIP_DATASET_CHANGE_FOR_DOMAINS = []
2 changes: 1 addition & 1 deletion superset_config.example.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,4 +190,4 @@ class CeleryConfig:
}

USER_DOMAIN_ROLE_EXPIRY = 60 # minutes

SKIP_DATASET_CHANGE_FOR_DOMAINS = []

0 comments on commit b322aab

Please sign in to comment.