Skip to content

Commit

Permalink
Fixed linter errors after adding styler
Browse files Browse the repository at this point in the history
  • Loading branch information
MICHAELMUNAVU83 committed Nov 30, 2023
1 parent 5473e0a commit 82abdd5
Show file tree
Hide file tree
Showing 21 changed files with 66 additions and 94 deletions.
3 changes: 1 addition & 2 deletions .credo.exs
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@
# You can customize the priority of any check
# Priority values are: `low, normal, high, higher`
#
{Credo.Check.Design.AliasUsage,
[priority: :low, if_nested_deeper_than: 2, if_called_more_often_than: 2]},
{Credo.Check.Design.AliasUsage, [priority: :low, if_nested_deeper_than: 2, if_called_more_often_than: 2]},
# You can also customize the exit_status of each check.
# If you don't want TODO comments to cause `mix credo` to fail, just
# set this value to 0 (zero).
Expand Down
2 changes: 1 addition & 1 deletion .formatter.exs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
import_deps: [:ecto, :ecto_sql, :phoenix],
subdirectories: ["priv/*/migrations"],
plugins: [Styler],
plugins: [Styler],
inputs: ["*.{heex,ex,exs}", "{config,lib,test}/**/*.{heex,ex,exs}", "priv/*/seeds.exs"]
]
3 changes: 1 addition & 2 deletions config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ config :elixir_conf_africa, ElixirConfAfrica.Mailer, adapter: Swoosh.Adapters.Lo
config :esbuild,
version: "0.17.11",
default: [
args:
~w(js/app.js --bundle --target=es2017 --outdir=../priv/static/assets --external:/fonts/* --external:/images/*),
args: ~w(js/app.js --bundle --target=es2017 --outdir=../priv/static/assets --external:/fonts/* --external:/images/*),
cd: Path.expand("../assets", __DIR__),
env: %{"NODE_PATH" => Path.expand("../deps", __DIR__)}
]
Expand Down
3 changes: 1 addition & 2 deletions config/prod.exs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import Config
# manifest is generated by the `mix assets.deploy` task,
# which you should run after static files are built and
# before starting your production server.
config :elixir_conf_africa, ElixirConfAfricaWeb.Endpoint,
cache_static_manifest: "priv/static/cache_manifest.json"
config :elixir_conf_africa, ElixirConfAfricaWeb.Endpoint, cache_static_manifest: "priv/static/cache_manifest.json"

# Configures Swoosh API Client
config :swoosh, api_client: Swoosh.ApiClient.Finch, finch_name: ElixirConfAfrica.Finch
Expand Down
1 change: 1 addition & 0 deletions lib/elixir_conf_africa/events/event.ex
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
defmodule ElixirConfAfrica.Events.Event do
@moduledoc false
use TypedEctoSchema

import Ecto.Changeset

typed_schema "events" do
Expand Down
5 changes: 2 additions & 3 deletions lib/elixir_conf_africa/ticket_types.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ defmodule ElixirConfAfrica.TicketTypes do
"""

import Ecto.Query, warn: false
alias ElixirConfAfrica.Repo

alias ElixirConfAfrica.Repo
alias ElixirConfAfrica.TicketTypes.TicketType

@doc """
Expand All @@ -23,8 +23,7 @@ defmodule ElixirConfAfrica.TicketTypes do
end

def add_quantity(ticket_type, quantity) do
ticket_type
|> Map.put(:quantity, quantity)
Map.put(ticket_type, :quantity, quantity)
end

@doc """
Expand Down
1 change: 1 addition & 0 deletions lib/elixir_conf_africa/ticket_types/ticket_type.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ defmodule ElixirConfAfrica.TicketTypes.TicketType do
@moduledoc false

use TypedEctoSchema

import Ecto.Changeset

typed_schema "ticket_types" do
Expand Down
15 changes: 6 additions & 9 deletions lib/elixir_conf_africa_web/components/core_components.ex
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ defmodule ElixirConfAfricaWeb.CoreComponents do
"""
use Phoenix.Component

alias Phoenix.LiveView.JS
import ElixirConfAfricaWeb.Gettext

alias Phoenix.LiveView.JS

@doc """
Renders a modal.
Expand Down Expand Up @@ -271,17 +272,15 @@ defmodule ElixirConfAfricaWeb.CoreComponents do
values: ~w(checkbox color date datetime-local email file hidden month number password
range radio search select tel text textarea time url week)

attr :field, Phoenix.HTML.FormField,
doc: "a form field struct retrieved from the form, for example: @form[:email]"
attr :field, Phoenix.HTML.FormField, doc: "a form field struct retrieved from the form, for example: @form[:email]"

attr :errors, :list, default: []
attr :checked, :boolean, doc: "the checked flag for checkbox inputs"
attr :prompt, :string, default: nil, doc: "the prompt for select inputs"
attr :options, :list, doc: "the options to pass to Phoenix.HTML.Form.options_for_select/2"
attr :multiple, :boolean, default: false, doc: "the multiple flag for select inputs"

attr :rest, :global,
include: ~w(accept autocomplete capture cols disabled form list max maxlength min minlength
attr :rest, :global, include: ~w(accept autocomplete capture cols disabled form list max maxlength min minlength
multiple pattern placeholder readonly required rows size step)

slot :inner_block
Expand Down Expand Up @@ -594,8 +593,7 @@ defmodule ElixirConfAfricaWeb.CoreComponents do
JS.show(js,
to: selector,
transition:
{"transition-all transform ease-out duration-300",
"opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",
{"transition-all transform ease-out duration-300", "opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",
"opacity-100 translate-y-0 sm:scale-100"}
)
end
Expand All @@ -605,8 +603,7 @@ defmodule ElixirConfAfricaWeb.CoreComponents do
to: selector,
time: 200,
transition:
{"transition-all transform ease-in duration-200",
"opacity-100 translate-y-0 sm:scale-100",
{"transition-all transform ease-in duration-200", "opacity-100 translate-y-0 sm:scale-100",
"opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"}
)
end
Expand Down
1 change: 1 addition & 0 deletions lib/elixir_conf_africa_web/components/layouts.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
defmodule ElixirConfAfricaWeb.Layouts do
@moduledoc false
use ElixirConfAfricaWeb, :html

embed_templates "layouts/*"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
defmodule ElixirConfAfricaWeb.EventLive.FormComponent do
@moduledoc false
use ElixirConfAfricaWeb, :live_component

alias ElixirConfAfrica.Events
Expand Down
3 changes: 2 additions & 1 deletion lib/elixir_conf_africa_web/live/home_live/index.ex
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
defmodule ElixirConfAfricaWeb.HomeLive.Index do
@moduledoc false
use ElixirConfAfricaWeb, :live_view
alias ElixirConfAfrica.Events

alias ElixirConfAfrica.Cart
alias ElixirConfAfrica.Events

def mount(_params, _session, socket) do
event_name = "ElixirConf Africa #{get_upcoming_year()}"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
defmodule ElixirConfAfricaWeb.TicketTypeLive.FormComponent do
@moduledoc false
use ElixirConfAfricaWeb, :live_component

alias ElixirConfAfrica.TicketTypes
Expand Down
6 changes: 2 additions & 4 deletions lib/elixir_conf_africa_web/live/ticket_type_live/index.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
defmodule ElixirConfAfricaWeb.TicketTypeLive.Index do
@moduledoc false
use ElixirConfAfricaWeb, :live_view

alias ElixirConfAfrica.TicketTypes
Expand Down Expand Up @@ -33,10 +34,7 @@ defmodule ElixirConfAfricaWeb.TicketTypeLive.Index do
end

@impl true
def handle_info(
{ElixirConfAfricaWeb.TicketTypeLive.FormComponent, {:saved, ticket_type}},
socket
) do
def handle_info({ElixirConfAfricaWeb.TicketTypeLive.FormComponent, {:saved, ticket_type}}, socket) do
{:noreply, stream_insert(socket, :ticket_types, ticket_type)}
end

Expand Down
5 changes: 3 additions & 2 deletions lib/elixir_conf_africa_web/telemetry.ex
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
defmodule ElixirConfAfricaWeb.Telemetry do
@moduledoc false
use Supervisor

import Telemetry.Metrics

def start_link(arg) do
Expand Down Expand Up @@ -70,8 +72,7 @@ defmodule ElixirConfAfricaWeb.Telemetry do
),
summary("elixir_conf_africa.repo.query.idle_time",
unit: {:native, :millisecond},
description:
"The time the connection spent waiting before being checked out for the query"
description: "The time the connection spent waiting before being checked out for the query"
),

# VM Metrics
Expand Down
88 changes: 29 additions & 59 deletions priv/repo/seeds.exs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
# We recommend using the bang functions (`insert!`, `update!`
# and so on) as they will fail if something goes wrong.

alias ElixirConfAfrica.Repo
alias ElixirConfAfrica.Events.Event
alias ElixirConfAfrica.Repo
alias ElixirConfAfrica.TicketTypes.TicketType

ticket_types_names = ["Early Bird", "Regular", "VIP/All Access", "Student"]
Expand All @@ -21,141 +21,111 @@ Enum.each(1..10, fn _num ->
datetime = Faker.DateTime.forward(Enum.random(1..30))

event =
%Event{
Repo.insert!(%Event{
name: Faker.Lorem.sentence(),
event_type: Faker.Lorem.sentence(1),
location: Faker.Address.En.street_address(),
description: Faker.Lorem.paragraph(),
start_date:
datetime
|> NaiveDateTime.truncate(:second),
start_date: NaiveDateTime.truncate(datetime, :second),
end_date:
datetime
|> NaiveDateTime.truncate(:second)
|> NaiveDateTime.add(Enum.random(1..5), :day)
}
|> Repo.insert!()
})

Enum.each(Enum.shuffle(ticket_types_names), fn type ->
%TicketType{
Repo.insert!(%TicketType{
event_id: event.id,
name: type,
description: Faker.Lorem.sentence(),
price: 0.0 + Enum.random(20..500),
number: Enum.random(100..500)
}
|> Repo.insert!()
})
end)
end)

# Almost random seed
datetime = Faker.DateTime.forward(Enum.random(1..30))

event =
%Event{
Repo.insert!(%Event{
name: "ElixirConf 2024",
event_type: "Conference",
location: "Nairobi",
description: "A very long and BEAMy description of some interestingly scary concept",
start_date:
datetime
|> NaiveDateTime.truncate(:second),
end_date:
datetime
|> NaiveDateTime.truncate(:second)
|> NaiveDateTime.add(Enum.random(1..5), :day)
}
|> Repo.insert!()
start_date: NaiveDateTime.truncate(datetime, :second),
end_date: datetime |> NaiveDateTime.truncate(:second) |> NaiveDateTime.add(Enum.random(1..5), :day)
})

Enum.each(Enum.shuffle(ticket_types_names), fn type ->
%TicketType{
Repo.insert!(%TicketType{
event_id: event.id,
name: type,
description: Faker.Lorem.sentence(),
price: 0.0 + Enum.random(20..500),
number: Enum.random(100..500)
}
|> Repo.insert!()
})
end)

datetime = Faker.DateTime.forward(Enum.random(1..30))

%Event{
Repo.insert!(%Event{
name: "BEAM: The Perfect Fit for Networks",
event_type: "Webinar",
location: "Zoom",
description: "A very long and BEAMy description of some interestingly scary concept",
start_date:
datetime
|> NaiveDateTime.truncate(:second),
end_date:
datetime
|> NaiveDateTime.truncate(:second)
|> NaiveDateTime.add(Enum.random(1..5), :day)
}
|> Repo.insert!()
start_date: NaiveDateTime.truncate(datetime, :second),
end_date: datetime |> NaiveDateTime.truncate(:second) |> NaiveDateTime.add(Enum.random(1..5), :day)
})

Enum.each(Enum.shuffle(ticket_types_names), fn type ->
%TicketType{
Repo.insert!(%TicketType{
event_id: event.id,
name: type,
description: Faker.Lorem.sentence(),
price: 0.0 + Enum.random(20..500),
number: Enum.random(100..500)
}
|> Repo.insert!()
})
end)

datetime = Faker.DateTime.forward(Enum.random(1..30))

%Event{
Repo.insert!(%Event{
name: "Learn You Some Erlang",
event_type: "Webinar",
location: "Somewhere Crazy",
description: "A very long and BEAMy description of some interestingly scary concept",
start_date: NaiveDateTime.truncate(datetime, :second),
end_date:
datetime
|> NaiveDateTime.truncate(:second)
|> NaiveDateTime.add(Enum.random(1..5), :day)
}
|> Repo.insert!()
end_date: datetime |> NaiveDateTime.truncate(:second) |> NaiveDateTime.add(Enum.random(1..5), :day)
})

Enum.each(Enum.shuffle(ticket_types_names), fn type ->
%TicketType{
Repo.insert!(%TicketType{
event_id: event.id,
name: type,
description: Faker.Lorem.sentence(),
price: 0.0 + Enum.random(20..500),
number: Enum.random(100..500)
}
|> Repo.insert!()
})
end)

datetime = Faker.DateTime.forward(Enum.random(1..30))

%Event{
Repo.insert!(%Event{
name: "Who Supervises The Supervisor",
event_type: "Webinar",
location: "Who Knows?",
description: "A very long and BEAMy description of some interestingly scary concept",
start_date:
datetime
|> NaiveDateTime.truncate(:second),
end_date:
datetime
|> NaiveDateTime.truncate(:second)
|> NaiveDateTime.add(Enum.random(1..5), :day)
}
|> Repo.insert!()
start_date: NaiveDateTime.truncate(datetime, :second),
end_date: datetime |> NaiveDateTime.truncate(:second) |> NaiveDateTime.add(Enum.random(1..5), :day)
})

Enum.each(Enum.shuffle(ticket_types_names), fn type ->
%TicketType{
Repo.insert!(%TicketType{
event_id: event.id,
name: type,
description: Faker.Lorem.sentence(),
price: 0.0 + Enum.random(20..500),
number: Enum.random(100..500)
}
|> Repo.insert!()
})
end)
3 changes: 2 additions & 1 deletion test/elixir_conf_africa/cart_test.exs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
defmodule ElixirConfAfrica.CartTest do
use ElixirConfAfrica.DataCase

alias ElixirConfAfrica.Cart

describe "Cart Functionaity" do
Expand Down Expand Up @@ -42,7 +43,7 @@ defmodule ElixirConfAfrica.CartTest do

assert Cart.add_to_cart([%{id: 1, quantity: 1}, %{id: 2, quantity: 1}], ticket_type.id) ==
[
ticket_type |> Map.put(:quantity, 1),
Map.put(ticket_type, :quantity, 1),
%{id: 1, quantity: 1},
%{id: 2, quantity: 1}
]
Expand Down
Loading

0 comments on commit 82abdd5

Please sign in to comment.