Skip to content

Commit ea2dbc1

Browse files
committed
Cleans up ladder in a few places
1 parent cb75cc4 commit ea2dbc1

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

lib/app/ladder.ex

+4-11
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,21 @@ defmodule App.Ladder do
1111
|> fetch_players
1212
end
1313

14-
defp clean_id(id) do
15-
id
16-
|> String.replace(~r/[^0-9]/, "")
17-
end
18-
1914
defp clean_ids(ids) when is_list(ids) do
2015
ids
21-
|> Enum.map(&clean_id/1)
16+
|> Enum.map(fn(x) -> String.replace(x, ~r/[^0-9]/, "") end)
2217
end
2318

24-
defp fetch_players(players = [head|tail]) do
19+
defp fetch_players([]), do: []
20+
21+
defp fetch_players(players) when is_list(players) do
2522
query = from p in App.Player, where: p.summoner_id in ^players
2623

2724
query
2825
|> App.Repo.all
2926
|> App.Repo.preload(:player_ranking)
3027
end
3128

32-
defp fetch_players([]) do
33-
[]
34-
end
35-
3629
defp fetch_from_redis(page) do
3730
Redis.query(["zrevrange",
3831
"rank_na",

0 commit comments

Comments
 (0)