Skip to content

Commit

Permalink
feat(alerts): Column for select tabs to send (#17604)
Browse files Browse the repository at this point in the history
* init

* init

* Modify migration

* Modify migration

* revert config, delete test file

* Rename column, modify migration

* rename a column

* Make extra non-nullable

* Fix typo
  • Loading branch information
m-ajay committed Dec 3, 2021
1 parent 8ff95f1 commit 1377465
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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")
2 changes: 1 addition & 1 deletion superset/models/alerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def __str__(self) -> str:

@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":
Expand Down
3 changes: 3 additions & 0 deletions superset/models/reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 1377465

Please sign in to comment.