refactoring of modules

This commit is contained in:
Owen
2025-01-13 14:29:47 +01:00
committed by Owen Rees
parent 1c84a97fb8
commit 498c5ebd6f
7 changed files with 124 additions and 112 deletions
+6 -11
View File
@@ -1,11 +1,11 @@
defmodule PlantIdDiscordBot.Metrics.Message do
def start() do
PlantIdDiscordBot.Metrics.get_all()
def send() do
PlantIdDiscordBot.Metrics.requests()
|> format_message()
|> send_message()
|> do_send_message()
end
def format_message(data) do
defp format_message(data) do
embeds =
Enum.map(data, fn {guild_id, metrics} ->
first_request_at =
@@ -30,15 +30,10 @@ defmodule PlantIdDiscordBot.Metrics.Message do
%{embeds: embeds}
end
def send_message(data) do
defp do_send_message(data) do
webhook_url = Application.get_env(:plantid_discord_bot, :metrics_webhook_url)
body = Jason.encode!(data)
headers = [
{"Content-Type", "application/json"}
]
headers = [{"Content-Type", "application/json"}]
HTTPoison.post!(webhook_url, body, headers)
end
end