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

Drop notifications tables and change notification context to messaging #4430

Merged
merged 2 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .iex.exs
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,8 @@ alias Sanbase.ExternalServices.ProjectInfo
alias Sanbase.Discourse.Api, as: DiscourseApi
alias Sanbase.Discourse.Config, as: DiscourseConfig

alias Sanbase.Notifications.Insight, as: NotificationsInsight
alias Sanbase.Notifications.Type, as: NotificationsType
alias Sanbase.Notifications.Discord
alias Sanbase.Messaging.Insight, as: NotificationsInsight
alias Sanbase.Messaging.Discord

alias Sanbase.Utils.{
JsonLogger,
Expand Down
2 changes: 1 addition & 1 deletion config/dev.exs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ config :sanbase, Oban.Web, queues: false
# When testing Oban.Scrapers jobs locally comment out these 2 lines
config :sanbase, Oban.Scrapers, queues: false

config :sanbase, Sanbase.Notifications.Insight, enabled: "false"
config :sanbase, Sanbase.Messaging.Insight, enabled: "false"

config :sanbase, Sanbase.KafkaExporter, producer: Sanbase.InMemoryKafka.Producer

Expand Down
2 changes: 1 addition & 1 deletion config/notifications_config.exs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Config

config :sanbase, Sanbase.Notifications.Insight,
config :sanbase, Sanbase.Messaging.Insight,
enabled: {:system, "INSIGHTS_DISCORD_NOTIFICATION_ENABLED", "true"},
webhook_url: {:system, "INSIGHTS_DISCORD_WEBHOOK_URL"},
insights_discord_publish_user: {:system, "INSIGHTS_DISCORD_PUBLISH_USER", "New Insight"}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
defmodule Sanbase.Billing.DiscordNotification do
alias Sanbase.Accounts.User
alias Sanbase.Notifications.Discord
alias Sanbase.Messaging.Discord
alias Sanbase.Billing.{Subscription, Plan, Product}

alias Sanbase.Utils.Config
Expand Down
2 changes: 1 addition & 1 deletion lib/sanbase/insight/post.ex
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ defmodule Sanbase.Insight.Post do
{:ok, post} ->
Task.Supervisor.async_nolink(Sanbase.TaskSupervisor, fn ->
post = Sanbase.Repo.preload(post, :user)
Sanbase.Notifications.Insight.publish_in_discord(post)
Sanbase.Messaging.Insight.publish_in_discord(post)
end)

TimelineEvent.maybe_create_event_async(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
defmodule Sanbase.Notifications.Discord do
defmodule Sanbase.Messaging.Discord do
@moduledoc ~s"""
Send notification to Discord and handle the response
"""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
defmodule Sanbase.Notifications.Insight do
defmodule Sanbase.Messaging.Insight do
require Mockery.Macro
alias Sanbase.Utils.Config
require Logger
Expand Down
94 changes: 0 additions & 94 deletions lib/sanbase/notifications/notification.ex

This file was deleted.

33 changes: 0 additions & 33 deletions lib/sanbase/notifications/type.ex

This file was deleted.

36 changes: 36 additions & 0 deletions priv/repo/migrations/20241017092520_drop_notifications_tables.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
defmodule Sanbase.Repo.Migrations.DropNotificationsTables do
use Ecto.Migration

def up do
drop(table(:notifications))
drop(table(:notification))
drop(table(:notification_type))
end

def down do
create table(:notification_type) do
add(:name, :string, null: false)
timestamps()
end

create table(:notifications) do
add(:project_id, references(:project), null: false)
add(:type_id, references(:notification_type), null: false)
add(:data, :string)

timestamps()
end

create(index(:notifications, [:project_id, :type_id]))

create(unique_index(:notification_type, [:name]))

create table(:notification) do
add(:project_id, references(:project), null: false)
add(:type_id, references(:notification_type), null: false)
timestamps()
end

create(index(:notification, [:project_id, :type_id]))
end
end
Loading