Skip to content

Commit

Permalink
Do not force screenshot on dashboard alerts
Browse files Browse the repository at this point in the history
  • Loading branch information
betodealmeida committed Dec 22, 2021
1 parent 7d59d29 commit ec2c200
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions superset-frontend/src/views/CRUD/alert/AlertReportModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ const DEFAULT_ALERT = {
sql: '',
validator_config_json: {},
validator_type: '',
force_screenshot: true,
force_screenshot: false,
grace_period: undefined,
};

Expand Down Expand Up @@ -513,7 +513,7 @@ const AlertReportModal: FunctionComponent<AlertReportModalProps> = ({
const data: any = {
...currentAlert,
type: isReport ? 'Report' : 'Alert',
force_screenshot: isReport ? 'false' : 'true',
force_screenshot: contentType === 'chart' && !isReport ? 'true' : 'false',
validator_type: conditionNotNull ? 'not null' : 'operator',
validator_config_json: conditionNotNull
? {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ def upgrade():
session = db.Session(bind=bind)

for report in session.query(ReportSchedule).all():
report.force_screenshot = report.type == "Alert"
# Update existing alerts that send chart screenshots so that the cache is
# bypassed. We don't turn this one for dashboards because (1) it's currently
# not supported but also because (2) it can be very expensive.
report.force_screenshot = report.type == "Alert" and report.chart_id is not None

session.commit()

Expand Down
3 changes: 1 addition & 2 deletions superset/models/reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,7 @@ class ReportSchedule(Model, AuditMixinNullable):
# Store the selected dashboard tabs etc.
extra = Column(Text, default="{}")

# (Reports) When generating a screenshot, bypass the cache? This is always true for
# Alerts.
# (Reports) When generating a screenshot, bypass the cache?
force_screenshot = Column(Boolean, default=False)

def __repr__(self) -> str:
Expand Down

0 comments on commit ec2c200

Please sign in to comment.