Skip to content

Commit

Permalink
Merge pull request #1720 from Logflare/fix/alerts-crud
Browse files Browse the repository at this point in the history
fix: Alerts changeset bug referencing Endpoints instead of AlertQuery
  • Loading branch information
Ziinc authored Oct 6, 2023
2 parents adce40e + 7a601e0 commit 964bf42
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
18 changes: 9 additions & 9 deletions lib/logflare_web/live/alerts/alerts_live.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ defmodule LogflareWeb.AlertsLive do

require Logger

alias Logflare.Endpoints
alias Logflare.Users
alias LogflareWeb.Utils
alias Logflare.Alerting
alias Logflare.Alerting.AlertQuery

embed_templates("actions/*", suffix: "_action")
embed_templates("components/*")
Expand All @@ -34,8 +33,6 @@ defmodule LogflareWeb.AlertsLive do
def mount(%{}, %{"user_id" => user_id}, socket) do
user = Users.get(user_id)

allow_access = Enum.any?([Utils.flag("endpointsOpenBeta"), user.endpoints_beta])

socket =
socket
|> assign(:user_id, user_id)
Expand All @@ -44,8 +41,7 @@ defmodule LogflareWeb.AlertsLive do
|> refresh()
|> assign(:query_result_rows, nil)
|> assign(:alert, nil)
|> assign(:endpoint_changeset, Endpoints.change_query(%Endpoints.Query{}))
|> assign(:allow_access, allow_access)
|> assign(:endpoint_changeset, Alerting.change_alert_query(%AlertQuery{}))
|> assign(:base_url, LogflareWeb.Endpoint.url())
|> assign(:parse_error_message, nil)
|> assign(:query_string, nil)
Expand All @@ -63,10 +59,14 @@ defmodule LogflareWeb.AlertsLive do
Alerting.get_alert_query_by(id: alert_id, user_id: socket.assigns.user_id)
end

socket = assign(socket, :alert, alert)

socket =
socket
|> assign(:alert, alert)
|> assign(:changeset, nil)
if socket.assigns.live_action == :edit do
assign(socket, :changeset, Alerting.change_alert_query(alert))
else
assign(socket, :changeset, nil)
end

{:noreply, socket}
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
"select timestamp, event_message from `YourApp.SourceName` \nwhere regexp_contains(event_message, 'error')",
class: "form-control form-control-margin",
id: "alert-query",
value: Map.get(@params_form.params, "query"),
style: "height: 20rem"
) %>
<%= error_tag(f, :query) %>
Expand Down

0 comments on commit 964bf42

Please sign in to comment.