chore: added more @spec
This commit is contained in:
@@ -15,7 +15,9 @@ defmodule BDS.CliSync.Notification do
|
||||
|
||||
def changeset(notification, attrs) do
|
||||
notification
|
||||
|> cast(attrs, [:entity_type, :entity_id, :action, :from_cli, :seen_at, :created_at], empty_values: [nil])
|
||||
|> cast(attrs, [:entity_type, :entity_id, :action, :from_cli, :seen_at, :created_at],
|
||||
empty_values: [nil]
|
||||
)
|
||||
|> validate_required([:entity_type, :entity_id, :action, :from_cli, :created_at])
|
||||
end
|
||||
end
|
||||
|
||||
@@ -24,7 +24,11 @@ defmodule BDS.CliSync.Watcher do
|
||||
@impl true
|
||||
def init(opts) do
|
||||
state = %{
|
||||
poll_interval_ms: normalize_positive_integer(Keyword.get(opts, :poll_interval_ms), @default_poll_interval_ms),
|
||||
poll_interval_ms:
|
||||
normalize_positive_integer(
|
||||
Keyword.get(opts, :poll_interval_ms),
|
||||
@default_poll_interval_ms
|
||||
),
|
||||
pubsub: Keyword.get(opts, :pubsub, BDS.PubSub)
|
||||
}
|
||||
|
||||
@@ -49,7 +53,11 @@ defmodule BDS.CliSync.Watcher do
|
||||
{:ok, _pruned} = CliSync.prune_notifications()
|
||||
|
||||
Enum.each(notifications, fn notification ->
|
||||
Phoenix.PubSub.broadcast(state.pubsub, topic(), {:entity_changed, notification_payload(notification)})
|
||||
Phoenix.PubSub.broadcast(
|
||||
state.pubsub,
|
||||
topic(),
|
||||
{:entity_changed, notification_payload(notification)}
|
||||
)
|
||||
end)
|
||||
|
||||
state
|
||||
|
||||
Reference in New Issue
Block a user