You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by gr...@apache.org on 2021/12/03 18:30:07 UTC
[superset] branch master updated: feat(alerts): Column for select tabs to send (#17604)
This is an automated email from the ASF dual-hosted git repository.
graceguo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git
The following commit(s) were added to refs/heads/master by this push:
new 1377465 feat(alerts): Column for select tabs to send (#17604)
1377465 is described below
commit 1377465a7d9f374500576b35683763c2cc29afe8
Author: Ajay M <aj...@outlook.com>
AuthorDate: Fri Dec 3 10:28:25 2021 -0800
feat(alerts): Column for select tabs to send (#17604)
* init
* init
* Modify migration
* Modify migration
* revert config, delete test file
* Rename column, modify migration
* rename a column
* Make extra non-nullable
* Fix typo
---
...e27eaf93db_add_extra_config_column_to_alerts.py | 50 ++++++++++++++++++++++
superset/models/alerts.py | 2 +-
superset/models/reports.py | 3 ++
3 files changed, 54 insertions(+), 1 deletion(-)
diff --git a/superset/migrations/versions/abe27eaf93db_add_extra_config_column_to_alerts.py b/superset/migrations/versions/abe27eaf93db_add_extra_config_column_to_alerts.py
new file mode 100644
index 0000000..c0cce0a
--- /dev/null
+++ b/superset/migrations/versions/abe27eaf93db_add_extra_config_column_to_alerts.py
@@ -0,0 +1,50 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+"""add_extra_config_column_to_alerts
+
+Revision ID: abe27eaf93db
+Revises: aea15018d53b
+Create Date: 2021-12-02 12:03:20.691171
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = "abe27eaf93db"
+down_revision = "aea15018d53b"
+
+import sqlalchemy as sa
+from alembic import op
+from sqlalchemy import String
+from sqlalchemy.sql import column, table
+
+connection = op.get_bind()
+
+report_schedule = table("report_schedule", column("extra", String))
+
+
+def upgrade():
+ with op.batch_alter_table("report_schedule") as batch_op:
+ batch_op.add_column(
+ sa.Column("extra", sa.Text(), nullable=True, default="{}",),
+ )
+ connection.execute(report_schedule.update().values({"extra": "{}"}))
+ with op.batch_alter_table("report_schedule") as batch_op:
+ batch_op.alter_column("extra", existing_type=sa.Text(), nullable=False)
+
+
+def downgrade():
+ op.drop_column("report_schedule", "extra")
diff --git a/superset/models/alerts.py b/superset/models/alerts.py
index 85bad4e..163dcf0 100644
--- a/superset/models/alerts.py
+++ b/superset/models/alerts.py
@@ -126,7 +126,7 @@ class Alert(Model, AuditMixinNullable):
@property
def pretty_config(self) -> str:
- """ String representing the comparison that will trigger a validator """
+ """String representing the comparison that will trigger a validator"""
config = json.loads(self.validator_config)
if self.validator_type.lower() == "operator":
diff --git a/superset/models/reports.py b/superset/models/reports.py
index 6ed769d..a0dc599 100644
--- a/superset/models/reports.py
+++ b/superset/models/reports.py
@@ -145,6 +145,9 @@ class ReportSchedule(Model, AuditMixinNullable):
# (Alerts/Reports) Unlock a possible stalled working state
working_timeout = Column(Integer, default=60 * 60 * 1)
+ # Store the selected dashboard tabs etc.
+ extra = Column(Text, default="{}")
+
def __repr__(self) -> str:
return str(self.name)