summaryrefslogtreecommitdiff
path: root/lib/lsg_web/controllers/alcoolog_controller.ex
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--lib/lsg_web/controllers/alcoolog_controller.ex44
1 files changed, 22 insertions, 22 deletions
diff --git a/lib/lsg_web/controllers/alcoolog_controller.ex b/lib/lsg_web/controllers/alcoolog_controller.ex
index 6542f15..3081762 100644
--- a/lib/lsg_web/controllers/alcoolog_controller.ex
+++ b/lib/lsg_web/controllers/alcoolog_controller.ex
@@ -1,12 +1,12 @@
-defmodule LSGWeb.AlcoologController do
- use LSGWeb, :controller
+defmodule NolaWeb.AlcoologController do
+ use NolaWeb, :controller
require Logger
- plug LSGWeb.ContextPlug when action not in [:token]
- plug LSGWeb.ContextPlug, [restrict: :public] when action in [:token]
+ plug NolaWeb.ContextPlug when action not in [:token]
+ plug NolaWeb.ContextPlug, [restrict: :public] when action in [:token]
def token(conn, %{"token" => token}) do
- case LSG.Token.lookup(token) do
+ case Nola.Token.lookup(token) do
{:ok, {:alcoolog, :index, network, channel}} -> index(conn, nil, network, channel)
err ->
Logger.debug("AlcoologControler: token #{inspect err} invalid")
@@ -21,8 +21,8 @@ defmodule LSGWeb.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 = LSG.IRC.AlcoologPlugin.get_full_statistics(profile_account.id)
- history = for {{nick, ts}, points, active, cl, deg, type, descr, meta} <- LSG.IRC.AlcoologPlugin.nick_history(profile_account) 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
%{
at: ts |> DateTime.from_unix!(:millisecond),
points: points,
@@ -50,7 +50,7 @@ defmodule LSGWeb.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 = LSG.IRC.AlcoologPlugin.get_full_statistics(profile_account.id)
+ stats = Nola.IRC.AlcoologPlugin.get_full_statistics(profile_account.id)
conn
|> put_resp_content_type("application/json")
@@ -67,7 +67,7 @@ defmodule LSGWeb.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 = LSG.IRC.AlcoologPlugin.user_over_time_gl(profile_account, count)
+ data = Nola.IRC.AlcoologPlugin.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 LSGWeb.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 = LSG.IRC.AlcoologPlugin.user_over_time(profile_account, count)
+ data = Nola.IRC.AlcoologPlugin.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 LSGWeb.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} <- LSG.IRC.AlcoologPlugin.nick_history(profile_account) do
+ history = for {{nick, ts}, points, active, cl, deg, type, descr, meta} <- Nola.IRC.AlcoologPlugin.nick_history(profile_account) do
%{
at: ts |> DateTime.from_unix!(:millisecond) |> DateTime.to_iso8601(),
points: points,
@@ -145,7 +145,7 @@ defmodule LSGWeb.AlcoologController do
}
end
last = List.last(history)
- {_, active} = LSG.IRC.AlcoologPlugin.user_stats(profile_account)
+ {_, active} = Nola.IRC.AlcoologPlugin.user_stats(profile_account)
last = %{last | active: active, at: DateTime.utc_now() |> DateTime.to_iso8601()}
history = history ++ [last]
@@ -163,7 +163,7 @@ defmodule LSGWeb.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} <- LSG.IRC.AlcoologAnnouncerPlugin.log(profile_account) do
+ history = for {_, date, value} <- Nola.IRC.AlcoologAnnouncerPlugin.log(profile_account) do
%{date: DateTime.to_iso8601(date), value: value}
end
conn
@@ -177,7 +177,7 @@ defmodule LSGWeb.AlcoologController do
end
def index(conn = %{assigns: %{account: account}}, %{"network" => network, "chan" => channel}) do
- index(conn, account, network, LSGWeb.reformat_chan(channel))
+ index(conn, account, network, NolaWeb.reformat_chan(channel))
end
def index(conn = %{assigns: %{account: account}}, _) do
@@ -187,7 +187,7 @@ defmodule LSGWeb.AlcoologController do
#def index(conn, params) do
# network = Map.get(params, "network")
# chan = if c = Map.get(params, "chan") do
- # LSGWeb.reformat_chan(c)
+ # NolaWeb.reformat_chan(c)
# end
# irc_conn = if network do
# IRC.Connection.get_network(network, chan)
@@ -223,12 +223,12 @@ defmodule LSGWeb.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(LSG.IRC.AlcoologPlugin.ETS, match)
+ drinks = :ets.select(Nola.IRC.AlcoologPlugin.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 = LSG.IRC.AlcoologPlugin.get_channel_statistics(account, network, channel)
+ stats = Nola.IRC.AlcoologPlugin.get_channel_statistics(account, network, channel)
top = Enum.reduce(drinks, %{}, fn({{{account_id, _}, vol, _, _, _, _, _, _}, _}, acc) ->
nick = Map.get(member_names, account_id)
@@ -245,7 +245,7 @@ defmodule LSGWeb.AlcoologController do
def index_gls_json(conn = %{assigns: %{account: account}}, %{"network" => network, "chan" => channel}) do
count = 30
- channel = LSGWeb.reformat_chan(channel)
+ channel = NolaWeb.reformat_chan(channel)
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)
@@ -266,7 +266,7 @@ defmodule LSGWeb.AlcoologController do
|> Enum.into(Map.new)
gls = Enum.reduce(members, filled, fn({account, _, _}, gls) ->
- Enum.reduce(LSG.IRC.AlcoologPlugin.user_over_time_gl(account, count), gls, fn({date, gl}, gls) ->
+ Enum.reduce(Nola.IRC.AlcoologPlugin.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 LSGWeb.AlcoologController do
def minisync(conn, %{"user_id" => user_id, "key" => key, "value" => value}) do
account = IRC.Account.get(user_id)
if account do
- ds = LSG.IRC.AlcoologPlugin.data_state()
- meta = LSG.IRC.AlcoologPlugin.get_user_meta(ds, account.id)
+ ds = Nola.IRC.AlcoologPlugin.data_state()
+ meta = Nola.IRC.AlcoologPlugin.get_user_meta(ds, account.id)
case Float.parse(value) do
{val, _} ->
new_meta = Map.put(meta, String.to_existing_atom(key), val)
- LSG.IRC.AlcoologPlugin.put_user_meta(ds, account.id, new_meta)
+ Nola.IRC.AlcoologPlugin.put_user_meta(ds, account.id, new_meta)
_ ->
conn
|> put_status(:unprocessable_entity)