summaryrefslogtreecommitdiff
path: root/lib/plugins/buffer.ex
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--lib/plugins/buffer.ex16
1 files changed, 11 insertions, 5 deletions
diff --git a/lib/plugins/buffer.ex b/lib/plugins/buffer.ex
index 42a435e..5f848ef 100644
--- a/lib/plugins/buffer.ex
+++ b/lib/plugins/buffer.ex
@@ -6,7 +6,12 @@ defmodule Nola.Plugins.Buffer do
def select_buffer(network, channel, limit \\ 50) do
import Ex2ms
- spec = fun do {{n, c, _}, m} when n == ^network and (c == ^channel or is_nil(c)) -> m end
+
+ spec =
+ fun do
+ {{n, c, _}, m} when n == ^network and (c == ^channel or is_nil(c)) -> m
+ end
+
:ets.select(@table, spec, limit)
end
@@ -18,6 +23,7 @@ defmodule Nola.Plugins.Buffer do
for e <- ~w(messages triggers events outputs) do
{:ok, _} = Registry.register(Nola.PubSub, e, plugin: __MODULE__)
end
+
{:ok, :ets.new(@table, [:named_table, :ordered_set, :protected])}
end
@@ -34,11 +40,11 @@ defmodule Nola.Plugins.Buffer do
defp ts(nil), do: ts(NaiveDateTime.utc_now())
defp ts(naive = %NaiveDateTime{}) do
- ts = naive
- |> DateTime.from_naive!("Etc/UTC")
- |> DateTime.to_unix()
+ ts =
+ naive
+ |> DateTime.from_naive!("Etc/UTC")
+ |> DateTime.to_unix()
-ts
end
-
end