Fix warnings, remove analyzers and create fact for champion played game
ci / docker (push) Successful in 7m38s
ci / docker (push) Successful in 7m38s
This commit is contained in:
@@ -1,6 +1,13 @@
|
||||
defmodule Storage.MatchStorage do
|
||||
@callback stream_files(String.t()) :: Enumerable.t()
|
||||
@callback get_match(String.t()) :: {:ok, Scrapper.Data.Match.t()} | {:error, :not_found}
|
||||
@callback save_match(String.t(), Scrapper.Data.Match.t()) :: :ok
|
||||
@callback list_matches() :: [map()]
|
||||
@callback store_match(match_id :: String.t(), match :: map(), path :: String.t()) :: String.t()
|
||||
@callback store_match(match_id :: String.t(), match_data :: String.t(), path :: String.t()) ::
|
||||
String.t()
|
||||
@callback store_match(
|
||||
match_id :: String.t(),
|
||||
match_data :: String.t(),
|
||||
bucket :: String.t(),
|
||||
path :: String.t()
|
||||
) ::
|
||||
String.t()
|
||||
end
|
||||
|
||||
@@ -2,50 +2,16 @@ defmodule Storage.MatchStorage.S3MatchStorage do
|
||||
require Logger
|
||||
@behaviour Storage.MatchStorage
|
||||
|
||||
def get_match(match_id) do
|
||||
""
|
||||
@impl true
|
||||
def get_match(_match_id) do
|
||||
end
|
||||
|
||||
@impl true
|
||||
def stream_files(path) do
|
||||
ExAws.S3.list_objects_v2(path)
|
||||
|> ExAws.stream!()
|
||||
end
|
||||
|
||||
@doc """
|
||||
Lists all files at the given path.
|
||||
|
||||
iex > Storage.MatchStorage.S3MatchStorage.list_files("matches")
|
||||
"""
|
||||
@impl true
|
||||
def list_files(path) do
|
||||
{:ok, %{:body => %{:contents => contents, next_continuation_token: next_continuation_token}}} =
|
||||
ExAws.S3.list_objects_v2(path)
|
||||
|> ExAws.request()
|
||||
|
||||
if next_continuation_token do
|
||||
list_files(path, contents, next_continuation_token)
|
||||
# |> Enum.map(fn %{key: key} -> key end)
|
||||
else
|
||||
contents
|
||||
# |> Enum.map(fn %{key: key} -> key end)
|
||||
end
|
||||
end
|
||||
|
||||
@spec list_files(String.t(), list(String.t()), String.t()) :: list(String.t())
|
||||
defp list_files(path, acc, continuation_token) do
|
||||
resp =
|
||||
{:ok,
|
||||
%{:body => %{:contents => contents, next_continuation_token: next_continuation_token}}} =
|
||||
ExAws.S3.list_objects_v2(path, continuation_token: continuation_token)
|
||||
|> ExAws.request()
|
||||
|
||||
if next_continuation_token == "" do
|
||||
acc ++ contents
|
||||
else
|
||||
list_files(path, acc ++ contents, next_continuation_token)
|
||||
end
|
||||
end
|
||||
|
||||
@doc """
|
||||
iex> Scrapper.Storage.S3MatchStorage.store_match "1", "content", "matches"
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user