Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove old alerts and configs keys #19261

Merged
merged 14 commits into from
Mar 25, 2022
22 changes: 0 additions & 22 deletions superset/cli/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,13 @@
# specific language governing permissions and limitations
# under the License.
import logging
from datetime import datetime, timedelta

import click
from colorama import Fore
from flask.cli import with_appcontext

import superset.utils.database as database_utils
from superset import app, security_manager
from superset.utils.celery import session_scope

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -88,23 +86,3 @@ def load_test_users_run() -> None:
password="general",
)
sm.get_session.commit()


@click.command()
@with_appcontext
def alert() -> None:
"""Run the alert scheduler loop"""
# this command is just for testing purposes
# pylint: disable=import-outside-toplevel
from superset.models.schedules import ScheduleType
from superset.tasks.schedules import schedule_window

click.secho("Processing one alert loop", fg="green")
with session_scope(nullpool=True) as session:
schedule_window(
report_type=ScheduleType.alert,
start_at=datetime.now() - timedelta(1000),
stop_at=datetime.now(),
resolution=6000,
session=session,
)
12 changes: 0 additions & 12 deletions superset/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1060,18 +1060,6 @@ def SQL_QUERY_MUTATOR( # pylint: disable=invalid-name,unused-argument
return sql


# Enable / disable scheduled email reports
#
# Warning: This config key is deprecated and will be removed in version 2.0.0"
ENABLE_SCHEDULED_EMAIL_REPORTS = False

# Enable / disable Alerts, where users can define custom SQL that
# will send emails with screenshots of charts or dashboards periodically
# if it meets the criteria
#
# Warning: This config key is deprecated and will be removed in version 2.0.0"
ENABLE_ALERTS = False

# ---------------------------------------------------
# Alerts & Reports
# ---------------------------------------------------
Expand Down
57 changes: 1 addition & 56 deletions superset/initialization/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,7 @@ def init_views(self) -> None:
from superset.reports.logs.api import ReportExecutionLogRestApi
from superset.security.api import SecurityRestApi
from superset.views.access_requests import AccessRequestsModelView
from superset.views.alerts import (
AlertLogModelView,
AlertModelView,
AlertObservationModelView,
AlertView,
ReportView,
)
from superset.views.alerts import AlertView
from superset.views.annotations import (
AnnotationLayerModelView,
AnnotationModelView,
Expand Down Expand Up @@ -184,10 +178,6 @@ def init_views(self) -> None:
from superset.views.log.api import LogRestApi
from superset.views.log.views import LogModelView
from superset.views.redirects import R
from superset.views.schedules import (
DashboardEmailScheduleView,
SliceEmailScheduleView,
)
from superset.views.sql_lab import (
SavedQueryView,
SavedQueryViewApi,
Expand Down Expand Up @@ -391,50 +381,6 @@ def init_views(self) -> None:
#
# Conditionally setup email views
#
if self.config["ENABLE_SCHEDULED_EMAIL_REPORTS"]:
logging.warning(
"ENABLE_SCHEDULED_EMAIL_REPORTS "
"is deprecated and will be removed in version 2.0.0"
)

appbuilder.add_separator(
"Manage", cond=lambda: self.config["ENABLE_SCHEDULED_EMAIL_REPORTS"]
)
appbuilder.add_view(
DashboardEmailScheduleView,
"Dashboard Email Schedules",
label=__("Dashboard Emails"),
category="Manage",
category_label=__("Manage"),
icon="fa-search",
menu_cond=lambda: self.config["ENABLE_SCHEDULED_EMAIL_REPORTS"],
)
appbuilder.add_view(
SliceEmailScheduleView,
"Chart Emails",
label=__("Chart Email Schedules"),
category="Manage",
category_label=__("Manage"),
icon="fa-search",
menu_cond=lambda: self.config["ENABLE_SCHEDULED_EMAIL_REPORTS"],
)

if self.config["ENABLE_ALERTS"]:
logging.warning(
"ENABLE_ALERTS is deprecated and will be removed in version 2.0.0"
)

appbuilder.add_view(
AlertModelView,
"Alerts",
label=__("Alerts"),
category="Manage",
category_label=__("Manage"),
icon="fa-exclamation-triangle",
menu_cond=lambda: bool(self.config["ENABLE_ALERTS"]),
)
appbuilder.add_view_no_menu(AlertLogModelView)
appbuilder.add_view_no_menu(AlertObservationModelView)

appbuilder.add_view(
AlertView,
Expand All @@ -445,7 +391,6 @@ def init_views(self) -> None:
icon="fa-exclamation-triangle",
menu_cond=lambda: feature_flag_manager.is_feature_enabled("ALERT_REPORTS"),
)
appbuilder.add_view_no_menu(ReportView)

appbuilder.add_view(
AccessRequestsModelView,
Expand Down
10 changes: 1 addition & 9 deletions superset/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,4 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
from . import (
alerts,
core,
datasource_access_request,
dynamic_plugins,
schedules,
sql_lab,
user_attributes,
)
from . import core, datasource_access_request, dynamic_plugins, sql_lab, user_attributes
176 changes: 0 additions & 176 deletions superset/models/alerts.py

This file was deleted.