Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Public Libs
Elixir
Notification Dispatcher
Commits
e84a9bb7
Commit
e84a9bb7
authored
Oct 27, 2020
by
Miguel Basticioto
Browse files
feat: schema de notification_message
parent
26fdc92e
Changes
1
Hide whitespace changes
Inline
Side-by-side
lib/schemas/notification_message.ex
0 → 100644
View file @
e84a9bb7
defmodule
NotificationDispatcher
.
Schema
.
NotificationMessage
do
use
Ecto
.
Schema
import
Ecto
.
Changeset
import
Ecto
.
Query
alias
NotificationDispatcher
.
Schema
.
NotificationMessage
@primary_key
{
:id
,
:binary_id
,
autogenerate:
true
}
schema
"notification_messages"
do
field
:title
,
:string
field
:message
,
:string
# 0 - Password Reset
field
:notification_type
,
:integer
# 0 - Notification / 1 - Email
field
:channel
,
:integer
field
:locale
,
:string
field
:dispatch_offsets
,
:string
timestamps
()
end
@doc
false
def
changeset
(
notification_message
,
attrs
)
do
notification_message
|>
cast
(
attrs
,
[
:title
,
:message
,
:notification_type
,
:channel
,
:locale
,
:dispatch_offsets
])
|>
validate_required
([
:title
,
:message
,
:notification_type
,
:channel
,
:locale
,
:dispatch_offsets
])
end
def
query_main
,
do
:
from
(
notification
in
NotificationMessage
,
as:
:notification
)
def
where
(
query
,
id
),
do
:
from
([
notification:
n
]
in
query
,
where:
n
.
id
==
^
id
)
def
where_channel
(
query
,
channel
),
do
:
from
([
notification:
n
]
in
query
,
where:
n
.
channel
==
^
channel
)
def
where_type
(
query
,
type
),
do
:
from
([
notification:
n
]
in
query
,
where:
n
.
notification_type
==
^
type
)
def
where_locale
(
query
,
locale
),
do
:
from
([
notification:
n
]
in
query
,
where:
n
.
locale
==
^
locale
)
def
limit
(
query
,
limit
),
do
:
from
([
notification:
n
]
in
query
,
limit:
^
limit
)
end
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment