diff options
Diffstat (limited to '')
-rw-r--r-- | lib/nola_web/controllers/alcoolog_controller.ex | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/lib/nola_web/controllers/alcoolog_controller.ex b/lib/nola_web/controllers/alcoolog_controller.ex index 3081762..3c812c5 100644 --- a/lib/nola_web/controllers/alcoolog_controller.ex +++ b/lib/nola_web/controllers/alcoolog_controller.ex @@ -21,8 +21,8 @@ defmodule NolaWeb.AlcoologController do days = String.to_integer(Map.get(params, "days", "180")) friend? = Enum.member?(IRC.Membership.friends(account), profile_account.id) if friend? do - stats = Nola.IRC.AlcoologPlugin.get_full_statistics(profile_account.id) - history = for {{nick, ts}, points, active, cl, deg, type, descr, meta} <- Nola.IRC.AlcoologPlugin.nick_history(profile_account) do + stats = Nola.Plugins.Alcoolog.get_full_statistics(profile_account.id) + history = for {{nick, ts}, points, active, cl, deg, type, descr, meta} <- Nola.Plugins.Alcoolog.nick_history(profile_account) do %{ at: ts |> DateTime.from_unix!(:millisecond), points: points, @@ -50,7 +50,7 @@ defmodule NolaWeb.AlcoologController do profile_account = IRC.Account.find_always_by_nick(network, nick, nick) friend? = Enum.member?(IRC.Membership.friends(account), profile_account.id) if friend? do - stats = Nola.IRC.AlcoologPlugin.get_full_statistics(profile_account.id) + stats = Nola.Plugins.Alcoolog.get_full_statistics(profile_account.id) conn |> put_resp_content_type("application/json") @@ -67,7 +67,7 @@ defmodule NolaWeb.AlcoologController do friend? = Enum.member?(IRC.Membership.friends(account), profile_account.id) count = String.to_integer(Map.get(params, "days", "180")) if friend? do - data = Nola.IRC.AlcoologPlugin.user_over_time_gl(profile_account, count) + data = Nola.Plugins.Alcoolog.user_over_time_gl(profile_account, count) delay = count*((24 * 60)*60) now = DateTime.utc_now() start_date = DateTime.utc_now() @@ -101,7 +101,7 @@ defmodule NolaWeb.AlcoologController do friend? = Enum.member?(IRC.Membership.friends(account), profile_account.id) count = String.to_integer(Map.get(params, "days", "180")) if friend? do - data = Nola.IRC.AlcoologPlugin.user_over_time(profile_account, count) + data = Nola.Plugins.Alcoolog.user_over_time(profile_account, count) delay = count*((24 * 60)*60) now = DateTime.utc_now() start_date = DateTime.utc_now() @@ -132,7 +132,7 @@ defmodule NolaWeb.AlcoologController do profile_account = IRC.Account.find_always_by_nick(network, nick, nick) friend? = Enum.member?(IRC.Membership.friends(account), profile_account.id) if friend? do - history = for {{nick, ts}, points, active, cl, deg, type, descr, meta} <- Nola.IRC.AlcoologPlugin.nick_history(profile_account) do + history = for {{nick, ts}, points, active, cl, deg, type, descr, meta} <- Nola.Plugins.Alcoolog.nick_history(profile_account) do %{ at: ts |> DateTime.from_unix!(:millisecond) |> DateTime.to_iso8601(), points: points, @@ -145,7 +145,7 @@ defmodule NolaWeb.AlcoologController do } end last = List.last(history) - {_, active} = Nola.IRC.AlcoologPlugin.user_stats(profile_account) + {_, active} = Nola.Plugins.Alcoolog.user_stats(profile_account) last = %{last | active: active, at: DateTime.utc_now() |> DateTime.to_iso8601()} history = history ++ [last] @@ -163,7 +163,7 @@ defmodule NolaWeb.AlcoologController do profile_account = IRC.Account.find_always_by_nick(network, nick, nick) friend? = Enum.member?(IRC.Membership.friends(account), profile_account.id) if friend? do - history = for {_, date, value} <- Nola.IRC.AlcoologAnnouncerPlugin.log(profile_account) do + history = for {_, date, value} <- Nola.Plugs.AlcoologAnnouncer.log(profile_account) do %{date: DateTime.to_iso8601(date), value: value} end conn @@ -223,12 +223,12 @@ defmodule NolaWeb.AlcoologController do members = IRC.Membership.expanded_members_or_friends(account, network, channel) members_ids = Enum.map(members, fn({account, _, nick}) -> account.id end) member_names = Enum.reduce(members, %{}, fn({account, _, nick}, acc) -> Map.put(acc, account.id, nick) end) - drinks = :ets.select(Nola.IRC.AlcoologPlugin.ETS, match) + drinks = :ets.select(Nola.Plugins.Alcoolog.ETS, match) |> Enum.filter(fn({{account, _}, _vol, _cur, _cl, _deg, _name, _cmt, _meta}) -> Enum.member?(members_ids, account) end) |> Enum.map(fn({{account, _}, _, _, _, _, _, _, _} = object) -> {object, Map.get(member_names, account)} end) |> Enum.sort_by(fn({{{_, ts}, _, _, _, _, _, _, _}, _}) -> ts end, &>/2) - stats = Nola.IRC.AlcoologPlugin.get_channel_statistics(account, network, channel) + stats = Nola.Plugins.Alcoolog.get_channel_statistics(account, network, channel) top = Enum.reduce(drinks, %{}, fn({{{account_id, _}, vol, _, _, _, _, _, _}, _}, acc) -> nick = Map.get(member_names, account_id) @@ -266,7 +266,7 @@ defmodule NolaWeb.AlcoologController do |> Enum.into(Map.new) gls = Enum.reduce(members, filled, fn({account, _, _}, gls) -> - Enum.reduce(Nola.IRC.AlcoologPlugin.user_over_time_gl(account, count), gls, fn({date, gl}, gls) -> + Enum.reduce(Nola.Plugins.Alcoolog.user_over_time_gl(account, count), gls, fn({date, gl}, gls) -> u = Map.get(gls, date, %{}) |> Map.put(Map.get(member_names, account.id, account.id), gl) Map.put(gls, date, u) @@ -302,12 +302,12 @@ defmodule NolaWeb.AlcoologController do def minisync(conn, %{"user_id" => user_id, "key" => key, "value" => value}) do account = IRC.Account.get(user_id) if account do - ds = Nola.IRC.AlcoologPlugin.data_state() - meta = Nola.IRC.AlcoologPlugin.get_user_meta(ds, account.id) + ds = Nola.Plugins.Alcoolog.data_state() + meta = Nola.Plugins.Alcoolog.get_user_meta(ds, account.id) case Float.parse(value) do {val, _} -> new_meta = Map.put(meta, String.to_existing_atom(key), val) - Nola.IRC.AlcoologPlugin.put_user_meta(ds, account.id, new_meta) + Nola.Plugins.Alcoolog.put_user_meta(ds, account.id, new_meta) _ -> conn |> put_status(:unprocessable_entity) |