Skip to content

Commit

Permalink
chore: remove references to default images
Browse files Browse the repository at this point in the history
  • Loading branch information
ruioliveira02 committed Dec 23, 2023
1 parent 302e408 commit a1fcd44
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 68 deletions.
24 changes: 7 additions & 17 deletions lib/mix/tasks/gen.badges.ex
Original file line number Diff line number Diff line change
Expand Up @@ -85,28 +85,18 @@ defmodule Mix.Tasks.Gen.Badges do
tokens: String.to_integer(tokens)
},
%{
avatar: %Plug.Upload{
filename: check_image_filename(image_path),
path: check_image_path(image_path)
}
avatar: get_avatar(image_path)
}
}
end)
end

defp check_image_filename(image_path) do
if is_nil(image_path) do
"missing-badge.svg"
else
String.split(image_path, "/") |> List.last()
end
end
defp get_avatar(nil), do: nil

defp check_image_path(image_path) do
if is_nil(image_path) do
"#{File.cwd!()}/assets/static/images/missing-badge.svg"
else
image_path
end
defp get_avatar(image_path) do
%Plug.Upload{
filename: String.split(image_path, "/") |> List.last(),
path: image_path
}
end
end
24 changes: 7 additions & 17 deletions lib/mix/tasks/gen.companies.ex
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,7 @@ defmodule Mix.Tasks.Gen.Companies do
tokens: String.to_integer(tokens)
},
%{
avatar: %Plug.Upload{
filename: check_image_filename(image_path),
path: check_image_path(image_path)
}
avatar: get_avatar(image_path)
},
%{
name: name,
Expand All @@ -87,20 +84,13 @@ defmodule Mix.Tasks.Gen.Companies do
end)
end

defp check_image_filename(image_path) do
if is_nil(image_path) do
"missing-badge.svg"
else
String.split(image_path, "/") |> List.last()
end
end
defp get_avatar(nil), do: nil

defp check_image_path(image_path) do
if is_nil(image_path) do
"#{File.cwd!()}/assets/static/images/missing-badge.svg"
else
image_path
end
defp get_avatar(image_path) do
%Plug.Upload{
filename: String.split(image_path, "/") |> List.last(),
path: image_path
}
end

defp sequence(list) do
Expand Down
24 changes: 7 additions & 17 deletions lib/mix/tasks/gen.prizes.ex
Original file line number Diff line number Diff line change
Expand Up @@ -45,29 +45,19 @@ defmodule Mix.Tasks.Gen.Prizes do
is_redeemable: convert_bool!(is_redeemable)
},
%{
avatar: %Plug.Upload{
filename: check_image_filename(image_path),
path: check_image_path(image_path)
}
avatar: get_avatar(image_path)
}
}
end)
end

defp check_image_filename(image_path) do
if String.trim(image_path) == "" do
"prize-missing.svg"
else
String.split(image_path, "/") |> List.last()
end
end
defp get_avatar(nil), do: nil

defp check_image_path(image_path) do
if String.trim(image_path) == "" do
"#{File.cwd!()}/assets/static/images/prize-missing.svg"
else
image_path
end
defp get_avatar(image_path) do
%Plug.Upload{
filename: String.split(image_path, "/") |> List.last(),
path: image_path
}
end

defp validate_probabilities(list) do
Expand Down
24 changes: 7 additions & 17 deletions lib/mix/tasks/gen.redeemables.ex
Original file line number Diff line number Diff line change
Expand Up @@ -46,29 +46,19 @@ defmodule Mix.Tasks.Gen.Redeemables do
is_redeemable: convert_bool!(is_redeemable)
},
%{
img: %Plug.Upload{
filename: check_image_filename(path_to_image),
path: check_image_path(path_to_image)
}
img: get_avatar(path_to_image)
}
}
end)
end

defp check_image_filename(image_path) do
if String.trim(image_path) == "" do
"redeemable-missing.svg"
else
String.split(image_path, "/") |> List.last()
end
end
defp get_avatar(nil), do: nil

defp check_image_path(image_path) do
if String.trim(image_path) == "" do
"#{File.cwd!()}/assets/static/images/redeemable-missing.svg"
else
image_path
end
defp get_avatar(image_path) do
%Plug.Upload{
filename: String.split(image_path, "/") |> List.last(),
path: image_path
}
end

defp sequence(list) do
Expand Down

0 comments on commit a1fcd44

Please sign in to comment.