JasonD28 commented on a change in pull request #10605:
URL: 
https://github.com/apache/incubator-superset/pull/10605#discussion_r480289764



##########
File path: superset/views/alerts.py
##########
@@ -47,6 +55,130 @@ class AlertLogModelView(
     )
 
 
+class AlertObservationModelView(
+    CompactCRUDMixin, SupersetModelView
+):  # pylint: disable=too-many-ancestors
+    datamodel = SQLAInterface(SQLObservation)
+    include_route_methods = {RouteMethod.LIST} | {"show"}
+    list_title = _("List Observations")
+    show_title = _("Show Observation")
+    list_columns = (
+        "dttm",
+        "value",
+        "error_msg",
+    )
+    label_columns = {
+        "error_msg": _("Error Message"),
+    }
+
+
+# TODO: add a button to the form to test if the SQL statment can run with no 
errors
+class SQLObserverInlineView(  # pylint: disable=too-many-ancestors
+    CompactCRUDMixin, SupersetModelView
+):
+    datamodel = SQLAInterface(SQLObserver)
+    include_route_methods = RouteMethod.RELATED_VIEW_SET | RouteMethod.API_SET
+    list_title = _("SQL Observers")
+    show_title = _("Show SQL Observer")
+    add_title = _("Add SQL Observer")
+    edit_title = _("Edit SQL Observer")
+
+    edit_columns = [
+        "name",
+        "alert",
+        "database",
+        "sql",
+    ]
+
+    add_columns = edit_columns
+
+    list_columns = [
+        "name",
+        "alert.label",
+        "database",
+    ]
+
+    label_columns = {
+        "name": _("Name"),
+        "alert": _("Alert"),
+        "database": _("Database"),
+        "sql": _("SQL"),
+    }
+
+    description_columns = {
+        "sql": _(
+            "A SQL statement that defines whether the alert should get 
triggered or "
+            "not. The query is expected to return either NULL or a number 
value."

Review comment:
       > add a comment that we also support numerical observations in the 
observer UI
   
   Implemented here




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to