Skip to content

Commit

Permalink
add event log
Browse files Browse the repository at this point in the history
  • Loading branch information
Grace committed Dec 15, 2020
1 parent 88a96b3 commit 420adcc
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions superset/connectors/sqla/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
from superset.db_engine_specs.base import TimestampExpression
from superset.errors import ErrorLevel, SupersetError, SupersetErrorType
from superset.exceptions import QueryObjectValidationError, SupersetSecurityException
from superset.extensions import event_logger
from superset.jinja_context import (
BaseTemplateProcessor,
ExtraCache,
Expand Down Expand Up @@ -1475,17 +1476,21 @@ def health_check(self, commit: bool = False, force: bool = False) -> None:

extra = self.extra_dict
# force re-run health check, or health check is updated
if force or not extra.get("health_check", {}).get("version") == check.version:
message = check(self)
if message:
extra["health_check"] = {"version": check.version, "message": message}
else:
extra.pop("health_check", None)
self.extra = json.dumps(extra)
if force or extra.get("health_check", {}).get("version") != check.version:
with event_logger.log_context(action="dataset_health_check"):
message = check(self)
if message:
extra["health_check"] = {
"version": check.version,
"message": message,
}
else:
extra.pop("health_check", None)
self.extra = json.dumps(extra)

db.session.merge(self)
if commit:
db.session.commit()
db.session.merge(self)
if commit:
db.session.commit()


sa.event.listen(SqlaTable, "after_insert", security_manager.set_perm)
Expand Down

0 comments on commit 420adcc

Please sign in to comment.