This commit is contained in:
parent
1c06ffb8a8
commit
0c0c7f1230
@ -9,20 +9,16 @@ defmodule LolAnalytics.Facts.ChampionPickedItem.FactProcessor do
|
|||||||
"""
|
"""
|
||||||
@impl true
|
@impl true
|
||||||
def process_game_at_url(url) do
|
def process_game_at_url(url) do
|
||||||
case HTTPoison.get(url) do
|
with {:ok, %HTTPoison.Response{status_code: 200, body: body}} <-
|
||||||
{:ok, %HTTPoison.Response{status_code: 200, body: body}} ->
|
HTTPoison.get(url),
|
||||||
process_game_data(body)
|
{:ok, decoded_match} <- Poison.decode(body, as: %LoLAPI.Model.MatchResponse{}) do
|
||||||
|
process_game_data(decoded_match)
|
||||||
{:error, %HTTPoison.Error{reason: reason}} ->
|
else
|
||||||
{:error, reason}
|
_ -> {:error, "Could not process data from #{url}"}
|
||||||
|
|
||||||
_ ->
|
|
||||||
{:error, "Could not fetch data from #{url}"}
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
defp process_game_data(data) do
|
defp process_game_data(decoded_match) do
|
||||||
decoded_match = Poison.decode!(data, as: %LoLAPI.Model.MatchResponse{})
|
|
||||||
participants = decoded_match.info.participants
|
participants = decoded_match.info.participants
|
||||||
version = extract_game_version(decoded_match)
|
version = extract_game_version(decoded_match)
|
||||||
|
|
||||||
|
@ -8,20 +8,16 @@ defmodule LolAnalytics.Facts.ChampionPickedSummonerSpell.FactProcessor do
|
|||||||
@impl true
|
@impl true
|
||||||
@spec process_game_at_url(String.t()) :: any()
|
@spec process_game_at_url(String.t()) :: any()
|
||||||
def process_game_at_url(url) do
|
def process_game_at_url(url) do
|
||||||
case HTTPoison.get(url) do
|
with {:ok, %HTTPoison.Response{status_code: 200, body: body}} <-
|
||||||
{:ok, %HTTPoison.Response{status_code: 200, body: body}} ->
|
HTTPoison.get(url),
|
||||||
process_game_data(body)
|
{:ok, decoded_match} <- Poison.decode(body, as: %LoLAPI.Model.MatchResponse{}) do
|
||||||
|
process_game_data(decoded_match)
|
||||||
{:error, %HTTPoison.Error{reason: reason}} ->
|
else
|
||||||
{:error, reason}
|
_ -> {:error, "Could not process data from #{url}"}
|
||||||
|
|
||||||
_ ->
|
|
||||||
{:error, "Could not fetch data from #{url}"}
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
defp process_game_data(data) do
|
defp process_game_data(decoded_match) do
|
||||||
decoded_match = Poison.decode!(data, as: %LoLAPI.Model.MatchResponse{})
|
|
||||||
participants = decoded_match.info.participants
|
participants = decoded_match.info.participants
|
||||||
version = extract_game_version(decoded_match)
|
version = extract_game_version(decoded_match)
|
||||||
|
|
||||||
|
@ -6,20 +6,16 @@ defmodule LolAnalytics.Facts.ChampionPlayedGame.FactProcessor do
|
|||||||
@impl true
|
@impl true
|
||||||
@spec process_game_at_url(String.t()) :: none()
|
@spec process_game_at_url(String.t()) :: none()
|
||||||
def process_game_at_url(url) do
|
def process_game_at_url(url) do
|
||||||
case HTTPoison.get(url) do
|
with {:ok, %HTTPoison.Response{status_code: 200, body: body}} <-
|
||||||
{:ok, %HTTPoison.Response{status_code: 200, body: body}} ->
|
HTTPoison.get(url),
|
||||||
process_game_data(body)
|
{:ok, decoded_match} <- Poison.decode(body, as: %LoLAPI.Model.MatchResponse{}) do
|
||||||
|
process_game_data(decoded_match)
|
||||||
{:error, %HTTPoison.Error{reason: reason}} ->
|
else
|
||||||
{:error, reason}
|
_ -> {:error, "Could not process data from #{url}"}
|
||||||
|
|
||||||
_ ->
|
|
||||||
{:error, "Could not fetch data from #{url}"}
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def process_game_data(data) do
|
def process_game_data(decoded_match) do
|
||||||
decoded_match = Poison.decode!(data, as: %LoLAPI.Model.MatchResponse{})
|
|
||||||
participants = decoded_match.info.participants
|
participants = decoded_match.info.participants
|
||||||
version = extract_game_version(decoded_match)
|
version = extract_game_version(decoded_match)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user