From 080b18c6befd5e002fbcf7d4603a70070fa4c992 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro?= Date: Fri, 3 May 2024 00:44:55 +0200 Subject: [PATCH] Add match url --- .../lib/lol_analytics/match/match_schema.ex | 3 ++- .../priv/repo/migrations/20240502223637_match_url.exs | 9 +++++++++ apps/scrapper/lib/scrapper/processor/match_processor.ex | 7 +++++-- 3 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 apps/lol_analytics/priv/repo/migrations/20240502223637_match_url.exs diff --git a/apps/lol_analytics/lib/lol_analytics/match/match_schema.ex b/apps/lol_analytics/lib/lol_analytics/match/match_schema.ex index b4ca006..c46d69c 100644 --- a/apps/lol_analytics/lib/lol_analytics/match/match_schema.ex +++ b/apps/lol_analytics/lib/lol_analytics/match/match_schema.ex @@ -5,13 +5,14 @@ defmodule LolAnalytics.Match.MatchSchema do schema "match" do field :match_id, :string field :processed, :boolean, default: false + field :match_url, :string timestamps() end def changeset(%__MODULE__{} = match, params \\ %{}) do match - |> cast(params, [:match_id, :processed]) + |> cast(params, [:match_id, :processed, :match_url]) |> validate_required([:match_id, :processed]) end diff --git a/apps/lol_analytics/priv/repo/migrations/20240502223637_match_url.exs b/apps/lol_analytics/priv/repo/migrations/20240502223637_match_url.exs new file mode 100644 index 0000000..55f7d2e --- /dev/null +++ b/apps/lol_analytics/priv/repo/migrations/20240502223637_match_url.exs @@ -0,0 +1,9 @@ +defmodule LoLAnalytics.Repo.Migrations.MatchUrl do + use Ecto.Migration + + def change do + alter table("match") do + add :match_url, :string + end + end +end diff --git a/apps/scrapper/lib/scrapper/processor/match_processor.ex b/apps/scrapper/lib/scrapper/processor/match_processor.ex index 45dd2c1..a27c04f 100644 --- a/apps/scrapper/lib/scrapper/processor/match_processor.ex +++ b/apps/scrapper/lib/scrapper/processor/match_processor.ex @@ -44,7 +44,7 @@ defmodule Scrapper.Processor.MatchProcessor do def process_resp({:ok, raw_match}, match_id) do decoded_match = Poison.decode!(raw_match, as: %Scrapper.Api.Model.MatchResponse{}) - Scrapper.Storage.S3MatchStorage.store_match(match_id, raw_match) + match_url = Scrapper.Storage.S3MatchStorage.store_match(match_id, raw_match) match = LolAnalytics.Match.MatchRepo.get_match(match_id) case match do @@ -52,7 +52,10 @@ defmodule Scrapper.Processor.MatchProcessor do LolAnalytics.Match.MatchRepo.insert_match(match_id) _ -> - LolAnalytics.Match.MatchRepo.update_match(match, %{:processed => true}) + LolAnalytics.Match.MatchRepo.update_match(match, %{ + :processed => true, + :match_url => match_url + }) end decoded_match.metadata.participants