Commit 8c2dc598 authored by Miguel Basticioto's avatar Miguel Basticioto
Browse files

feat: tirado mock do repo

parent 5b349673
......@@ -4,17 +4,17 @@ defmodule NotificationDispatcher.Context.NotificationsContext do
"""
import Ecto.Query, warn: false
alias Api.Repo
def get_repo(), do: Application.fetch_env!(:notification_dispatcher, :repo)
alias NotificationDispatcher.Schema.NotificationMessage
def get_notification_message!(id), do: Repo.get!(NotificationMessage, id)
def get_notification_message!(id), do: get_repo().get!(NotificationMessage, id)
def get_one_notification_message!(channel) do
NotificationMessage.query_main()
|> NotificationMessage.where_channel(channel)
|> NotificationMessage.limit(1)
|> Repo.one()
|> get_repo().one()
end
def get_by_type_and_language(type, language) do
......@@ -22,23 +22,23 @@ defmodule NotificationDispatcher.Context.NotificationsContext do
|> NotificationMessage.where_type(type)
|> NotificationMessage.where_locale(language)
|> NotificationMessage.limit(1)
|> Repo.one()
|> get_repo().one()
end
def get_by_type(type) do
NotificationMessage.query_main()
|> NotificationMessage.where_type(type)
|> NotificationMessage.limit(1)
|> Repo.one()
|> get_repo().one()
end
def create_notification_message(attrs \\ %{}) do
%NotificationMessage{}
|> NotificationMessage.changeset(attrs)
|> Repo.insert()
|> get_repo().insert()
end
def delete_notification_message(%NotificationMessage{} = notification_message) do
Repo.delete(notification_message)
get_repo().delete(notification_message)
end
end
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment