diff --git a/README.md b/README.md index 75f7046ece..817b8041d1 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,6 @@ For Mac Machines, if unable to download Erlang via `asdf` then run: ```sh brew install erlang@23 -cp -r /opt/homebrew/opt/erlang@23/lib/erlang ~/.asdf/installs/erlang/23.1.5 -asdf reshim erlang 23.1.5 +cp -r /opt/homebrew/opt/erlang@23/lib/erlang ~/.asdf/installs/erlang/23.3 +asdf reshim erlang 23.3 ``` \ No newline at end of file diff --git a/lib/console/graphql/users.ex b/lib/console/graphql/users.ex index 1e1e2af98b..bafbb1eb44 100644 --- a/lib/console/graphql/users.ex +++ b/lib/console/graphql/users.ex @@ -2,9 +2,11 @@ defmodule Console.GraphQl.Users do use Console.GraphQl.Schema.Base alias Console.GraphQl.Resolvers.User alias Console.Middleware.{Authenticated, AdminRequired, AllowJwt} + alias Console.Schema.Notification.{Severity, Status} enum_from_list :permission, Console.Schema.Role, :permissions, [] - ecto_enum :severity, Console.Schema.Notification.Severity + ecto_enum :severity, Severity + ecto_enum :notification_status, Status input_object :user_attributes do field :name, :string @@ -119,6 +121,7 @@ defmodule Console.GraphQl.Users do field :title, non_null(:string) field :description, :string field :fingerprint, non_null(:string) + field :status, :notification_status field :labels, :map field :annotations, :map field :repository, non_null(:string) diff --git a/lib/console/schema/notification.ex b/lib/console/schema/notification.ex index fe3031953f..6af50e568c 100644 --- a/lib/console/schema/notification.ex +++ b/lib/console/schema/notification.ex @@ -2,11 +2,13 @@ defmodule Console.Schema.Notification do use Piazza.Ecto.Schema defenum Severity, none: 0, low: 1, medium: 2, high: 3, critical: 4 + defenum Status, firing: 0, resolved: 1 schema "notifications" do field :title, :string field :description, :string field :repository, :string + field :status, Status field :labels, :map field :annotations, :map field :fingerprint, :string @@ -31,7 +33,7 @@ defmodule Console.Schema.Notification do from(n in query, order_by: ^order) end - @valid ~w(title description repository labels annotations fingerprint seen_at severity)a + @valid ~w(title description repository labels annotations fingerprint seen_at severity status)a def changeset(model, attrs \\ %{}) do model diff --git a/lib/console/services/alertmanager.ex b/lib/console/services/alertmanager.ex index 38bcb5838f..53bd065833 100644 --- a/lib/console/services/alertmanager.ex +++ b/lib/console/services/alertmanager.ex @@ -37,6 +37,7 @@ defmodule Console.Services.Alertmanager do labels: alert.labels, annotations: alert.annotations, repository: repo, + status: alert.status, severity: Map.get(alert.labels || %{}, "severity", :none), seen_at: Timex.now() }) diff --git a/priv/repo/migrations/20221118165510_add_notification_status.exs b/priv/repo/migrations/20221118165510_add_notification_status.exs new file mode 100644 index 0000000000..b5d4f8f627 --- /dev/null +++ b/priv/repo/migrations/20221118165510_add_notification_status.exs @@ -0,0 +1,9 @@ +defmodule Console.Repo.Migrations.AddNotificationStatus do + use Ecto.Migration + + def change do + alter table(:notifications) do + add :status, :integer, default: 0 + end + end +end diff --git a/test/console/services/alertmanager_test.exs b/test/console/services/alertmanager_test.exs index 3d8bbcb64e..17dd7c1d27 100644 --- a/test/console/services/alertmanager_test.exs +++ b/test/console/services/alertmanager_test.exs @@ -48,6 +48,7 @@ defmodule Console.Services.AlertmanagerTest do assert notif.title == alert.summary assert notif.fingerprint == alert.fingerprint assert notif.seen_at + assert notif.status == :firing assert notif.severity == :critical assert_receive {:event, %PubSub.NotificationCreated{item: found}}