Commit 5e1d79bf authored by Peter van der meulen's avatar Peter van der meulen

Renamed some modules for ease and added docs

parent 35d9d816
......@@ -2,7 +2,7 @@ defmodule AuroraBot.LiveMetrics do
@moduledoc """
Aurora Metrics.
The aurora metrics fetch, parse and format the important questions of there
The aurora metrics fetch, parse and format the important questions of there
being live metrics of aurora's happening right now.
"""
......@@ -39,7 +39,7 @@ defmodule AuroraBot.LiveMetrics do
## Example
iex> get_kiruna_mag_graph_average()
[-50.1123]
-50.1123
"""
def get_kiruna_mag_graph_average do
......@@ -97,7 +97,7 @@ defmodule AuroraBot.LiveMetrics do
## Example
iex> pkp_and_chances()
3
%{city_chances: %{harnosand: 0, ostersund: 0, sundsvall: 0, umea: 0}, kp: 1}
"""
def get_kp_and_chances do
......@@ -118,7 +118,7 @@ defmodule AuroraBot.LiveMetrics do
## Example
iex> kp_to_chance(7, :sundsvall)
70%
70
"""
def kp_to_chance(kp, location) do
......
......@@ -15,8 +15,8 @@ defmodule AuroraBot.Report.Live do
alias AuroraBot.LiveMetrics
alias AuroraBot.Weather
alias AuroraBot.Report.Store
alias AuroraBot.Report.Slack
alias AuroraBot.Report.ToStore
alias AuroraBot.Report.ToSlack
alias __MODULE__
@derive {Jason.Encoder, only: [:updated_at, :kp, :clouds, :chances]}
......@@ -56,7 +56,7 @@ defmodule AuroraBot.Report.Live do
"""
def run! do
report = create!()
Store.live(report)
ToStore.live!(report)
send_slack_message(report)
:ok
end
......@@ -85,7 +85,7 @@ defmodule AuroraBot.Report.Live do
defp send_message(report) do
true = Cachex.put!(:base, "slack-report", report.kp, ttl: :timer.hours(3))
Slack.send!(
ToSlack.send!(
"LIVE. \n New live data from IRF in Kiruna suggests that northern lights" <>
" can be seen in Sweden.\n The calculated KP is #{report.kp}.",
[
......
defmodule AuroraBot.Report.Slack do
defmodule AuroraBot.Report.ToSlack do
# https://bitbucket.org/mittmedia/newsletter-service-legacy/src/master/app/models/slack_bot.rb
def send!(text, attachments) do
......
defmodule AuroraBot.Report.Store do
def live(report) do
defmodule AuroraBot.Report.ToStore do
def live!(report) do
json_report = Jason.encode!(report, pretty: true)
File.write!("public/aurora_data.json", json_report)
File.write!("public/kp.txt", Integer.to_string(report.kp))
......
Markdown is supported
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