From a1fcd441c3aac8568457833ca344d92759630bb3 Mon Sep 17 00:00:00 2001 From: Rui Oliveira Date: Sat, 23 Dec 2023 22:44:55 +0000 Subject: [PATCH] chore: remove references to default images --- lib/mix/tasks/gen.badges.ex | 24 +++++++----------------- lib/mix/tasks/gen.companies.ex | 24 +++++++----------------- lib/mix/tasks/gen.prizes.ex | 24 +++++++----------------- lib/mix/tasks/gen.redeemables.ex | 24 +++++++----------------- 4 files changed, 28 insertions(+), 68 deletions(-) diff --git a/lib/mix/tasks/gen.badges.ex b/lib/mix/tasks/gen.badges.ex index aa2315bf..650e511b 100644 --- a/lib/mix/tasks/gen.badges.ex +++ b/lib/mix/tasks/gen.badges.ex @@ -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 diff --git a/lib/mix/tasks/gen.companies.ex b/lib/mix/tasks/gen.companies.ex index fa28f06f..96c06fc8 100644 --- a/lib/mix/tasks/gen.companies.ex +++ b/lib/mix/tasks/gen.companies.ex @@ -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, @@ -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 diff --git a/lib/mix/tasks/gen.prizes.ex b/lib/mix/tasks/gen.prizes.ex index 511023b3..374698ff 100644 --- a/lib/mix/tasks/gen.prizes.ex +++ b/lib/mix/tasks/gen.prizes.ex @@ -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 diff --git a/lib/mix/tasks/gen.redeemables.ex b/lib/mix/tasks/gen.redeemables.ex index ae4508b9..6c0bc301 100644 --- a/lib/mix/tasks/gen.redeemables.ex +++ b/lib/mix/tasks/gen.redeemables.ex @@ -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