Skip to content

Commit

Permalink
Fixed Configs and naming conventions
Browse files Browse the repository at this point in the history
  • Loading branch information
MICHAELMUNAVU83 committed Dec 2, 2024
1 parent 6530850 commit 5d281f2
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 22 deletions.
10 changes: 5 additions & 5 deletions config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,19 @@ config :animina, :default_potential_partner_maximum_age, 100
config :animina, :default_potential_partner_minimum_age, 18

# confugures the difference in age if no maximum or minimum age is set
config :animina, :default_potential_partner_age_difference, 10
config :animina, :default_partner_age_offset, 10

# Configures the maximum height for potential partners
config :animina, :default_potential_partner_maximum_height, 300
config :animina, :default_potential_partner_maximum_height, 225

# Configures the minimum height for potential partners
config :animina, :default_potential_partner_minimum_height, 0

# Configures the maximum height difference for potential partners
config :animina, :default_potential_partner_height_difference, 10
config :animina, :default_partner_height_offset, 10

# Configures the default search range for potential partners
config :animina, :default_potential_partner_search_range, 10_000
# Configures the default search range for potential partners in km
config :animina, :default_potential_partner_search_range_in_km, 10_000

config :animina,
ecto_repos: [Animina.Repo],
Expand Down
8 changes: 4 additions & 4 deletions lib/animina_web/components/beta_registration_components.ex
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ defmodule AniminaWeb.BetaRegistrationComponents do
class="block text-sm font-medium leading-6 text-gray-900 dark:text-white"
>
<%= with_locale(@language, fn -> %>
<%= gettext("Minimum height") %>
<%= gettext("Minimum %{height}", height: "height") %>
<% end) %>
</label>
<div phx-feedback-for={@f[:minimum_partner_height].name} class="mt-2">
Expand Down Expand Up @@ -360,7 +360,7 @@ defmodule AniminaWeb.BetaRegistrationComponents do
class="block text-sm font-medium leading-6 text-gray-900 dark:text-white"
>
<%= with_locale(@language, fn -> %>
<%= gettext("Maximum height") %>
<%= gettext("Maximum %{height}", height: "height") %>
<% end) %>
</label>
<div phx-feedback-for={@f[:maximum_partner_height].name} class="mt-2">
Expand Down Expand Up @@ -396,7 +396,7 @@ defmodule AniminaWeb.BetaRegistrationComponents do
class="block text-sm font-medium leading-6 text-gray-900 dark:text-white"
>
<%= with_locale(@language, fn -> %>
<%= gettext("Minimum age") %>
<%= gettext("Minimum %{age}", age: "age") %>
<% end) %>
</label>
<div phx-feedback-for={@f[:minimum_partner_age].name} class="mt-2">
Expand Down Expand Up @@ -429,7 +429,7 @@ defmodule AniminaWeb.BetaRegistrationComponents do
class="block text-sm font-medium leading-6 text-gray-900 dark:text-white"
>
<%= with_locale(@language, fn -> %>
<%= gettext("Maximum age") %>
<%= gettext("Maximum %{age}", age: "age") %>
<% end) %>
</label>
<div phx-feedback-for={@f[:maximum_partner_age].name} class="mt-2">
Expand Down
26 changes: 13 additions & 13 deletions lib/animina_web/potential_partner.ex
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ defmodule AniminaWeb.PotentialPartner do
User
|> Ash.Query.for_read(:read)
|> Ash.Query.sort(Ash.Sort.expr_sort(fragment("RANDOM()")))
|> beta_registration_partner_gender_query(user)
|> beta_registration_partner_height_query(user)
|> beta_registration_partner_age_query(user)
|> beta_registration_partner_geo_query(user)
|> registration_partner_gender_query(user)
|> registration_partner_height_query(user)
|> registration_partner_age_query(user)
|> registration_partner_geo_query(user)
|> partner_completed_registration_query(user)
|> partner_not_under_investigation_query(user)
|> partner_not_banned_query(user)
Expand Down Expand Up @@ -168,7 +168,7 @@ defmodule AniminaWeb.PotentialPartner do
|> Ash.Query.filter(gender: [eq: user.partner_gender])
end

defp beta_registration_partner_gender_query(query, user) do
defp registration_partner_gender_query(query, user) do
if user["gender"] == "" do
query
else
Expand All @@ -177,7 +177,7 @@ defmodule AniminaWeb.PotentialPartner do
end
end

defp beta_registration_partner_height_query(query, user) do
defp registration_partner_height_query(query, user) do
max_height = conditional_maximum_height(user["height"], user["maximum_partner_height"])
min_height = conditional_minimum_height(user["height"], user["minimum_partner_height"])

Expand All @@ -186,7 +186,7 @@ defmodule AniminaWeb.PotentialPartner do
|> Ash.Query.filter(height >= ^min_height)
end

defp beta_registration_partner_age_query(query, user) do
defp registration_partner_age_query(query, user) do
if user["birthday"] == "" do
query
else
Expand All @@ -211,7 +211,7 @@ defmodule AniminaWeb.PotentialPartner do
end
end

defp beta_registration_partner_geo_query(query, user) do
defp registration_partner_geo_query(query, user) do
if user["zip_code"] == "" do
query
else
Expand All @@ -229,7 +229,7 @@ defmodule AniminaWeb.PotentialPartner do
end

defp conditional_maximum_age(age, "") do
age + Application.get_env(:animina, :default_potential_partner_age_difference)
age + Application.get_env(:animina, :default_partner_age_offset)
end

defp conditional_maximum_age(_, max_age) do
Expand All @@ -241,7 +241,7 @@ defmodule AniminaWeb.PotentialPartner do
end

defp conditional_minimum_age(age, "") do
age + Application.get_env(:animina, :default_potential_partner_age_difference)
age + Application.get_env(:animina, :default_partner_age_offset)
end

defp conditional_minimum_age(_, min_age) do
Expand All @@ -256,7 +256,7 @@ defmodule AniminaWeb.PotentialPartner do
defp conditional_maximum_height(height, "") do
# We add a 10cm buffer to the user's height if the user does not specify a maximum height
String.to_integer(height) +
Application.get_env(:animina, :default_potential_partner_height_difference)
Application.get_env(:animina, :default_partner_height_offset)
end

defp conditional_maximum_height(_height, maximum_partner_height) do
Expand All @@ -271,7 +271,7 @@ defmodule AniminaWeb.PotentialPartner do
defp conditional_minimum_height(height, "") do
# We remove a 10cm buffer to the user's height if the user does not specify a minimum height
String.to_integer(height) -
Application.get_env(:animina, :default_potential_partner_height_difference)
Application.get_env(:animina, :default_partner_height_offset)
end

defp conditional_minimum_height(_, minimum_partner_height) do
Expand Down Expand Up @@ -314,7 +314,7 @@ defmodule AniminaWeb.PotentialPartner do
def get_nearby_cities(zip_code, search_range) do
search_range =
if search_range == "" do
Application.get_env(:animina, :default_potential_partner_search_range)
Application.get_env(:animina, :default_potential_partner_search_range_in_km)
else
String.to_integer(search_range)
end
Expand Down

0 comments on commit 5d281f2

Please sign in to comment.