diff --git a/lib/lanpartyseating/logic/autoassign_logic.ex b/lib/lanpartyseating/logic/autoassign_logic.ex index 47e8fe8..8c3920c 100644 --- a/lib/lanpartyseating/logic/autoassign_logic.ex +++ b/lib/lanpartyseating/logic/autoassign_logic.ex @@ -4,56 +4,51 @@ defmodule Lanpartyseating.AutoAssignLogic do alias Lanpartyseating.StationLogic, as: StationLogic alias Lanpartyseating.Repo, as: Repo - def register_station(uid) do - if uid == "" do - %{type: "error", message: "Please fill all the fields"} - else - # TODO: verify that badge uid exists and continue using serial_key. Else error - - # Get last assigned station - las = - LastAssignedStation - |> Repo.one() - - # Warp around the first station we look from when we reach the maximum number of stations - settings = SettingsLogic.get_settings() - next_station = rem(las.last_assigned_station, settings.columns * settings.rows) + 1 - - stations = StationLogic.get_all_stations_sorted_by_number() - - # Find the first result matching this condition - # The stations collection is split in half and we swap the end with the start so that - # we iterate on the last part first. This is so we search from the current index, but we still search all the stations. - result = - Enum.find( - Enum.drop(stations, next_station - 1) ++ Enum.take(stations, next_station - 1), - fn element -> - case StationLogic.get_station_status(element.station) do - %{status: :available, reservation: _} -> true - _ -> false - end + def register_station(_uid) do + # TODO: verify that badge uid exists and continue using serial_key. + + # Get last assigned station + las = + LastAssignedStation + |> Repo.one() + + # Warp around the first station we look from when we reach the maximum number of stations + {:ok, settings} = SettingsLogic.get_settings() + next_station = rem(las.last_assigned_station, settings.columns * settings.rows) + 1 + + {:ok, stations} = StationLogic.get_all_stations_sorted_by_number() + + # Find the first result matching this condition + # The stations collection is split in half and we swap the end with the start so that + # we iterate on the last part first. This is so we search from the current index, but we still search all the stations. + valid_stations = + Enum.find( + Enum.drop(stations, next_station - 1) ++ Enum.take(stations, next_station - 1), + fn element -> + case StationLogic.get_station_status(element.station) do + %{status: :available, reservation: _} -> true + _ -> false end - ) - - case result do - nil -> - nil - - result2 -> - next_station = result2.station.station_number - - # The station is registered to participant. Update the last reserved station in DB. - las = - Ecto.Changeset.change(las, - last_assigned_station: next_station, - last_assigned_station_date: DateTime.truncate(DateTime.utc_now(), :second) - ) - - case Repo.update(las) do - {:ok, _} -> next_station - {:error, error} -> error - end - end + end + ) + + case valid_stations do + nil -> {:error, "No available stations"} + + station -> + next_station_number = station.station.station_number + + # The station is registered to participant. Update the last reserved station in DB. + las = + Ecto.Changeset.change(las, + last_assigned_station: next_station, + last_assigned_station_date: DateTime.truncate(DateTime.utc_now(), :second) + ) + + case update = Repo.update(las) do + {:ok, _} -> {:ok, next_station_number} + _ -> update + end end end end diff --git a/lib/lanpartyseating/logic/badges_logic.ex b/lib/lanpartyseating/logic/badges_logic.ex index ae5dc7c..fbb87ff 100644 --- a/lib/lanpartyseating/logic/badges_logic.ex +++ b/lib/lanpartyseating/logic/badges_logic.ex @@ -6,9 +6,14 @@ defmodule Lanpartyseating.BadgesLogic do def get_badge(uid) do min_uid = String.upcase(uid) - from(s in Badge, - where: s.uid == ^min_uid - ) - |> Repo.one() + badge = from(s in Badge, + where: s.uid == ^min_uid + ) + |> Repo.one() + + case badge do + nil -> {:error, "Unknown badge serial number"} + _ -> {:ok, badge} + end end end diff --git a/lib/lanpartyseating/logic/reservation_logic.ex b/lib/lanpartyseating/logic/reservation_logic.ex index 858d449..2ce20ca 100644 --- a/lib/lanpartyseating/logic/reservation_logic.ex +++ b/lib/lanpartyseating/logic/reservation_logic.ex @@ -8,114 +8,111 @@ defmodule Lanpartyseating.ReservationLogic do alias Lanpartyseating.PubSub, as: PubSub alias LanpartyseatingWeb.Endpoint, as: Endpoint + def create_reservation(_station_number, _duration, "") do + {:error, "Please fill all the fields"} + end + def create_reservation(station_number, duration, uid) do - if uid == "" do - {:error, "Please fill all the fields"} - else - # Verifying that badge exists - badge = BadgesLogic.get_badge(uid) - - if badge == nil do - {:error, "Unknown badge serial number"} - else - station = StationLogic.get_station(station_number) - - if station == nil do - {:error, "Unknown station number"} - else - isAvailable = - case StationLogic.get_station_status(station).status do - :reserved -> false - :occupied -> false - :broken -> false - :available -> true - end - - if isAvailable == true do - now = DateTime.truncate(DateTime.utc_now(), :second) - end_time = DateTime.add(now, duration, :minute) - - case Repo.insert(%Reservation{ - duration: duration, - badge: badge.serial_key, - station_id: station.id, - start_date: now, - end_date: end_time - }) do - {:ok, updated} -> - Phoenix.PubSub.broadcast( - PubSub, - "station_update", - {:stations, StationLogic.get_all_stations(now)} - ) - - Endpoint.broadcast!( - "desktop:all", - "new_reservation", - %{ - station_number: station_number, - # reservation: updated - } - ) - - Logger.debug("Broadcasted station status change to occupied") - - DynamicSupervisor.start_child( - Lanpartyseating.ExpirationTaskSupervisor, - {Lanpartyseating.Tasks.ExpireReservation, {end_time, updated.id}} - ) - - Logger.debug("Created expiration task for reservation #{updated.id}") - {:ok, updated} - end - else - {:error, "Station is not available"} - end - end + {:ok, badge} = BadgesLogic.get_badge(uid) + {:ok, station} = StationLogic.get_station(station_number) + + is_available = + case StationLogic.get_station_status(station).status do + :reserved -> false + :occupied -> false + :broken -> false + :available -> true end + + case is_available do + true -> + Logger.debug("Station is available") + now = DateTime.truncate(DateTime.utc_now(), :second) + end_time = DateTime.add(now, duration, :minute) + + case Repo.insert(%Reservation{ + duration: duration, + badge: badge.serial_key, + station_id: station.id, + start_date: now, + end_date: end_time + }) do + {:ok, updated} -> + {:ok, stations} = StationLogic.get_all_stations(now) + Phoenix.PubSub.broadcast( + PubSub, + "station_update", + {:stations, stations} + ) + + Endpoint.broadcast!( + "desktop:all", + "new_reservation", + %{ + station_number: station_number, + # reservation: updated + } + ) + + Logger.debug("Broadcasted station status change to occupied") + + DynamicSupervisor.start_child( + Lanpartyseating.ExpirationTaskSupervisor, + {Lanpartyseating.Tasks.ExpireReservation, {end_time, updated.id}} + ) + + Logger.debug("Created expiration task for reservation #{updated.id}") + {:ok, updated} + end + false -> + Logger.debug("Station is not available") + {:error, "Station is not available"} end end def cancel_reservation(id, reason) do - from(r in Reservation, - where: r.station_id == ^id, - where: is_nil(r.deleted_at), - join: s in assoc(r, :station), - preload: [station: s] - ) - # There should, in theory, only be one non-deleted reservation for a station but let's clean up - # if that turns out not to be the case. - |> Repo.all() - |> Enum.map(fn res -> - reservation = - Ecto.Changeset.change(res, - incident: reason, - deleted_at: DateTime.truncate(DateTime.utc_now(), :second) - ) - - case Repo.update(reservation) do - {:ok, reservation} -> - GenServer.cast(:"expire_reservation_#{res.id}", :terminate) - - Endpoint.broadcast!( - "desktop:all", - "cancel_reservation", - %{ - station_number: reservation.station.station_number, - # reservation: updated - } + cancelled = + from(r in Reservation, + where: r.station_id == ^id, + where: is_nil(r.deleted_at), + join: s in assoc(r, :station), + preload: [station: s] + ) + # There should, in theory, only be one non-deleted reservation for a station but let's clean up + # if that turns out not to be the case. + |> Repo.all() + |> Enum.map(fn res -> + reservation = + Ecto.Changeset.change(res, + incident: reason, + deleted_at: DateTime.truncate(DateTime.utc_now(), :second) ) - Phoenix.PubSub.broadcast( - PubSub, - "station_update", - {:stations, StationLogic.get_all_stations()} - ) + case Repo.update(reservation) do + {:ok, reservation} -> + GenServer.cast(:"expire_reservation_#{res.id}", :terminate) - reservation - # let it crash - # {:error, _} -> ... - end - end) + Endpoint.broadcast!( + "desktop:all", + "cancel_reservation", + %{ + station_number: reservation.station.station_number, + # reservation: updated + } + ) + + {:ok, stations} = StationLogic.get_all_stations() + + Phoenix.PubSub.broadcast( + PubSub, + "station_update", + {:stations, stations} + ) + + reservation + end + end) + + {:ok, List.last(cancelled)} end end diff --git a/lib/lanpartyseating/logic/settings_logic.ex b/lib/lanpartyseating/logic/settings_logic.ex index 244eca6..3ab73e4 100644 --- a/lib/lanpartyseating/logic/settings_logic.ex +++ b/lib/lanpartyseating/logic/settings_logic.ex @@ -1,13 +1,20 @@ defmodule Lanpartyseating.SettingsLogic do import Ecto.Query + require Logger alias Lanpartyseating.Setting, as: Setting alias Lanpartyseating.LastAssignedSeat, as: LastAssignedSeat alias Lanpartyseating.Repo, as: Repo def get_settings do - Setting - |> last(:inserted_at) - |> Repo.one() + settings = + Setting + |> last(:inserted_at) + |> Repo.one() + + case settings do + nil -> {:error, "No settings found"} + _ -> {:ok, settings} + end end def save_settings( @@ -50,9 +57,6 @@ defmodule Lanpartyseating.SettingsLogic do vertical_trailing: vertical_trailing ) - case Repo.update(settings) do - {:ok, result} -> result - {:error, _} -> nil - end + Repo.update(settings) end end diff --git a/lib/lanpartyseating/logic/station_logic.ex b/lib/lanpartyseating/logic/station_logic.ex index 6acb3e8..e663ebf 100644 --- a/lib/lanpartyseating/logic/station_logic.ex +++ b/lib/lanpartyseating/logic/station_logic.ex @@ -1,6 +1,7 @@ defmodule Lanpartyseating.StationLogic do import Ecto.Query use Timex + alias Ecto.Changeset alias Lanpartyseating.PubSub, as: PubSub alias Lanpartyseating.StationLogic, as: StationLogic alias Lanpartyseating.Reservation, as: Reservation @@ -40,9 +41,15 @@ defmodule Lanpartyseating.StationLogic do ) |> Repo.all() - Enum.map(stations, fn station -> - Map.merge(%{station: station}, get_station_status(station)) - end) + case stations do + [] -> {:error, "No stations found"} + _ -> + stations_map = + Enum.map(stations, fn station -> + Map.merge(%{station: station}, get_station_status(station)) + end) + {:ok, stations_map} + end end def set_station_broken(station_number, is_broken) do @@ -56,15 +63,18 @@ defmodule Lanpartyseating.StationLogic do is_closed: is_broken ) - case Repo.update(station) do - {:ok, result} -> + update = Repo.update(station) + + case update do + {:ok, _} -> + {:ok, stations} = StationLogic.get_all_stations() Phoenix.PubSub.broadcast( PubSub, "station_update", - {:stations, StationLogic.get_all_stations()} + {:stations, stations} ) - result - {:error, _} -> nil + update + _ -> update end end @@ -96,15 +106,18 @@ defmodule Lanpartyseating.StationLogic do ) |> Repo.all() - Enum.map(stations, fn station -> - Map.merge(%{station: station}, get_station_status(station)) - end) + stations_map = + Enum.map(stations, fn station -> + Map.merge(%{station: station}, get_station_status(station)) + end) + + {:ok, stations_map} end def get_station(station_number, now \\ DateTime.utc_now()) do tournament_buffer = DateTime.add(DateTime.utc_now(), 45, :minute) - from(s in Station, + station = from(s in Station, order_by: [asc: s.id], where: is_nil(s.deleted_at), where: s.station_number == ^station_number, @@ -128,18 +141,26 @@ defmodule Lanpartyseating.StationLogic do ] ) |> Repo.one() + + case station do + nil -> {:error, "Station not found"} + _ -> {:ok, station} + end end def save_station_positions(table) do Repo.delete_all(Station) - table - |> Enum.each(fn row -> - row - |> Enum.each(fn station_number -> - Repo.insert(%Station{station_number: station_number, display_order: station_number}) + positions = + table + |> Enum.flat_map(fn row -> + row + |> Enum.map(fn station_number -> + Changeset.change(%Station{station_number: station_number, display_order: station_number}) + end) end) - end) + + {:ok, Repo.insert_all(Station, positions)} end def get_station_status(station) do diff --git a/lib/lanpartyseating/logic/tournaments_logic.ex b/lib/lanpartyseating/logic/tournaments_logic.ex index 171a278..5ebbe02 100644 --- a/lib/lanpartyseating/logic/tournaments_logic.ex +++ b/lib/lanpartyseating/logic/tournaments_logic.ex @@ -31,10 +31,13 @@ defmodule Lanpartyseating.TournamentsLogic do end def get_upcoming_tournaments do - from(t in Tournament, - where: t.end_date > from_now(0, "second"), - where: is_nil(t.deleted_at) - ) |> Repo.all() + tournaments = + from(t in Tournament, + where: t.end_date > from_now(0, "second"), + where: is_nil(t.deleted_at) + ) |> Repo.all() + + {:ok, tournaments} end def create_tournament(name, start_time, duration) do @@ -52,10 +55,11 @@ defmodule Lanpartyseating.TournamentsLogic do {Lanpartyseating.Tasks.ExpireTournament, {tournament.end_date, tournament.id}} ) + {:ok, tournaments} = get_upcoming_tournaments() Phoenix.PubSub.broadcast( PubSub, "tournament_update", - {:tournaments, get_upcoming_tournaments()} + {:tournaments, tournaments} ) {:ok, tournament} end @@ -73,28 +77,30 @@ defmodule Lanpartyseating.TournamentsLogic do deleted_at: DateTime.truncate(DateTime.utc_now(), :second) ) - case Repo.update(tournament) do - {:ok, struct} -> + case updated = Repo.update(tournament) do + {:ok, _} -> + {:ok, stations} = StationLogic.get_all_stations() + {:ok, tournaments} = get_upcoming_tournaments() GenServer.cast(:"expire_tournament_#{id}", :terminate) GenServer.cast(:"start_tournament_#{id}", :terminate) Phoenix.PubSub.broadcast( PubSub, "station_update", - {:stations, StationLogic.get_all_stations()} + {:stations, stations} ) Phoenix.PubSub.broadcast( PubSub, "tournament_update", - {:tournaments, get_upcoming_tournaments()} + {:tournaments, tournaments} ) - {:ok, struct} + updated end end) end def create_tournament_reservations_by_range(start_station, end_station, tournament_id) do # Input validation - settings = SettingsLogic.get_settings() + {:ok, settings} = SettingsLogic.get_settings() cond do start_station < 1 or start_station > settings.columns * settings.rows -> @@ -121,7 +127,7 @@ defmodule Lanpartyseating.TournamentsLogic do } end) - inserted = Repo.insert_all(TournamentReservation, reservations) + Repo.insert_all(TournamentReservation, reservations) Phoenix.PubSub.broadcast( PubSub, @@ -129,7 +135,7 @@ defmodule Lanpartyseating.TournamentsLogic do {:stations, StationLogic.get_all_stations()} ) - {:ok, inserted} + {:ok, reservations} end end end diff --git a/lib/lanpartyseating/tasks/expire_reservation.ex b/lib/lanpartyseating/tasks/expire_reservation.ex index 1cc0194..f87399e 100644 --- a/lib/lanpartyseating/tasks/expire_reservation.ex +++ b/lib/lanpartyseating/tasks/expire_reservation.ex @@ -49,10 +49,11 @@ defmodule Lanpartyseating.Tasks.ExpireReservation do {:ok, _} -> Logger.debug("Reservation #{reservation_id} expired") + {:ok, stations} = StationLogic.get_all_stations() Phoenix.PubSub.broadcast( PubSub, "station_update", - {:stations, StationLogic.get_all_stations()} + {:stations, stations} ) end {:stop, :normal, reservation_id} diff --git a/lib/lanpartyseating/tasks/expire_tournament.ex b/lib/lanpartyseating/tasks/expire_tournament.ex index 4265b5f..41761da 100644 --- a/lib/lanpartyseating/tasks/expire_tournament.ex +++ b/lib/lanpartyseating/tasks/expire_tournament.ex @@ -28,16 +28,18 @@ defmodule Lanpartyseating.Tasks.ExpireTournament do def handle_info(:expire_tournament, tournament_id) do Logger.debug("Expiring tournament #{tournament_id}") + {:ok, tournaments} = TournamentsLogic.get_upcoming_tournaments() Phoenix.PubSub.broadcast( PubSub, "tournament_update", - {:tournaments, TournamentsLogic.get_upcoming_tournaments()} + {:tournaments, tournaments} ) + {:ok, stations} = StationLogic.get_all_stations() Phoenix.PubSub.broadcast( PubSub, "station_update", - {:stations, StationLogic.get_all_stations()} + {:stations, stations} ) {:stop, :normal, tournament_id} diff --git a/lib/lanpartyseating/tasks/start_tournament.ex b/lib/lanpartyseating/tasks/start_tournament.ex index fd3ae71..38aacb4 100644 --- a/lib/lanpartyseating/tasks/start_tournament.ex +++ b/lib/lanpartyseating/tasks/start_tournament.ex @@ -31,10 +31,11 @@ defmodule Lanpartyseating.Tasks.StartTournament do def handle_info(:start_tournament, tournament_id) do Logger.debug("Starting tournament #{tournament_id}") + {:ok, stations} = StationLogic.get_all_stations() Phoenix.PubSub.broadcast( PubSub, "station_update", - {:stations, StationLogic.get_all_stations()} + {:stations, stations} ) from(r in TournamentReservation, @@ -43,7 +44,7 @@ defmodule Lanpartyseating.Tasks.StartTournament do preload: [station: s] ) |> Repo.all() - |> Enum.map(fn res -> + |> Enum.each(fn res -> Endpoint.broadcast( "desktop:all", "tournament_start", diff --git a/lib/lanpartyseating_web/live/autoassign_live.ex b/lib/lanpartyseating_web/live/autoassign_live.ex index dfe427d..b135f3e 100644 --- a/lib/lanpartyseating_web/live/autoassign_live.ex +++ b/lib/lanpartyseating_web/live/autoassign_live.ex @@ -11,31 +11,20 @@ defmodule LanpartyseatingWeb.AutoAssignLive do {:ok, socket} end + def handle_event("submit_reservation", %{"uid" => ""}, socket) do + {:noreply, assign(socket, :message, "Empty badge number submitted")} + end + def handle_event("submit_reservation", %{"uid" => uid}, socket) do message = - if String.length(uid) > 0 do - case AutoAssignLogic.register_station(uid) do - nil -> - "No station available. Please wait for a station to be freed and scan your badge again." - - number -> - # TODO: Handle case where create_reservation failed. It's possible that the function - # fails to assign the requested station. - - ReservationLogic.create_reservation(number, 45, uid) - - ## TODO: Create username and password in AD + case AutoAssignLogic.register_station(uid) do + {:error, error} -> + "No station available. Please wait for a station to be freed and scan your badge again. (#{error})" - ## TODO: Display the ID of the reserved station, all station have a username and password that relates to their ID - ## The ID is the one of the next available station. People who come in group should scan their - ## badge one after another if they want to be togheter. + {:ok, number} -> + {:ok, _} = ReservationLogic.create_reservation(number, 45, uid) - "Your assigned station is: " <> - to_string(number) <> - " (make this message disappear after 5 seconds with a nice fade out)" - end - else - "Empty badge number submitted" + "Your assigned station is: #{to_string(number)} (make this message disappear after 5 seconds with a nice fade out)" end {:noreply, assign(socket, :message, message)} diff --git a/lib/lanpartyseating_web/live/cancellation_live.ex b/lib/lanpartyseating_web/live/cancellation_live.ex index 42f29b7..aa41162 100644 --- a/lib/lanpartyseating_web/live/cancellation_live.ex +++ b/lib/lanpartyseating_web/live/cancellation_live.ex @@ -6,8 +6,8 @@ defmodule LanpartyseatingWeb.CancellationLive do alias Lanpartyseating.PubSub, as: PubSub def mount(_params, _session, socket) do - settings = SettingsLogic.get_settings() - stations = StationLogic.get_all_stations() + {:ok, settings} = SettingsLogic.get_settings() + {:ok, stations} = StationLogic.get_all_stations() if connected?(socket) do Phoenix.PubSub.subscribe(PubSub, "station_update") @@ -38,7 +38,7 @@ defmodule LanpartyseatingWeb.CancellationLive do ) do registration_error = nil - ReservationLogic.create_reservation( + {:ok, _} = ReservationLogic.create_reservation( String.to_integer(station_number), String.to_integer(duration), badge_number @@ -56,7 +56,7 @@ defmodule LanpartyseatingWeb.CancellationLive do %{"station_id" => id, "station_number" => _station_number, "cancel_reason" => reason}, socket ) do - ReservationLogic.cancel_reservation( + {:ok, _} = ReservationLogic.cancel_reservation( String.to_integer(id), reason ) @@ -69,10 +69,10 @@ defmodule LanpartyseatingWeb.CancellationLive do %{"station_number" => station_number}, socket ) do - StationLogic.set_station_broken( - String.to_integer(station_number), - true - ) + {:ok, _} = StationLogic.set_station_broken( + String.to_integer(station_number), + true + ) {:noreply, socket} end @@ -82,7 +82,7 @@ defmodule LanpartyseatingWeb.CancellationLive do %{"station_number" => station_number}, socket ) do - StationLogic.set_station_broken( + {:ok, _} = StationLogic.set_station_broken( String.to_integer(station_number), false ) diff --git a/lib/lanpartyseating_web/live/display_live.ex b/lib/lanpartyseating_web/live/display_live.ex index bcf57fe..cc28250 100644 --- a/lib/lanpartyseating_web/live/display_live.ex +++ b/lib/lanpartyseating_web/live/display_live.ex @@ -6,8 +6,9 @@ defmodule LanpartyseatingWeb.DisplayLive do alias Lanpartyseating.StationLogic, as: StationLogic def mount(_params, _session, socket) do - settings = SettingsLogic.get_settings() - tournaments = TournamentsLogic.get_upcoming_tournaments() + {:ok, settings} = SettingsLogic.get_settings() + {:ok, stations} = StationLogic.get_all_stations() + {:ok, tournaments} = TournamentsLogic.get_upcoming_tournaments() if connected?(socket) do Phoenix.PubSub.subscribe(PubSub, "station_update") @@ -22,7 +23,7 @@ defmodule LanpartyseatingWeb.DisplayLive do |> assign(:row_trailing, settings.horizontal_trailing) |> assign(:colpad, settings.column_padding) |> assign(:rowpad, settings.row_padding) - |> assign(:stations, StationLogic.get_all_stations()) + |> assign(:stations, stations) |> assign(:tournaments, tournaments) {:ok, socket} diff --git a/lib/lanpartyseating_web/live/selfsign_live.ex b/lib/lanpartyseating_web/live/selfsign_live.ex index 79b12d6..f8a2a5b 100644 --- a/lib/lanpartyseating_web/live/selfsign_live.ex +++ b/lib/lanpartyseating_web/live/selfsign_live.ex @@ -6,8 +6,8 @@ defmodule LanpartyseatingWeb.SelfSignLive do alias Lanpartyseating.PubSub, as: PubSub def mount(_params, _session, socket) do - settings = SettingsLogic.get_settings() - stations = StationLogic.get_all_stations() + {:ok, settings} = SettingsLogic.get_settings() + {:ok, stations} = StationLogic.get_all_stations() if connected?(socket) do Phoenix.PubSub.subscribe(PubSub, "station_status") diff --git a/lib/lanpartyseating_web/live/settings_live.ex b/lib/lanpartyseating_web/live/settings_live.ex index 1ebed08..40dd5c4 100644 --- a/lib/lanpartyseating_web/live/settings_live.ex +++ b/lib/lanpartyseating_web/live/settings_live.ex @@ -57,7 +57,7 @@ defmodule LanpartyseatingWeb.SettingsLive do end def mount(_params, _session, socket) do - settings = Lanpartyseating.SettingsLogic.get_settings() + {:ok, settings} = Lanpartyseating.SettingsLogic.get_settings() socket = socket @@ -174,9 +174,9 @@ defmodule LanpartyseatingWeb.SettingsLive do s = socket.assigns - Lanpartyseating.StationLogic.save_station_positions(socket.assigns.table) + {:ok, _} = Lanpartyseating.StationLogic.save_station_positions(socket.assigns.table) - Lanpartyseating.SettingsLogic.save_settings( + {:ok, _} = Lanpartyseating.SettingsLogic.save_settings( s.rows, s.columns, s.rowpad, diff --git a/mix.exs b/mix.exs index 416c436..da2875a 100644 --- a/mix.exs +++ b/mix.exs @@ -56,7 +56,8 @@ defmodule Lanpartyseating.Mixfile do {:opentelemetry_liveview, "~> 1.0.0-rc"}, {:opentelemetry_cowboy, "~> 0.2"}, {:heartcheck, "~> 0.4"}, - {:prom_ex, "~> 1.8.0"} + {:prom_ex, "~> 1.8.0"}, + {:credo, "~> 1.7", only: [:dev, :test], runtime: false} ] end diff --git a/mix.lock b/mix.lock index feab97c..1172913 100644 --- a/mix.lock +++ b/mix.lock @@ -1,5 +1,6 @@ %{ "acceptor_pool": {:hex, :acceptor_pool, "1.0.0", "43c20d2acae35f0c2bcd64f9d2bde267e459f0f3fd23dab26485bf518c281b21", [:rebar3], [], "hexpm", "0cbcd83fdc8b9ad2eee2067ef8b91a14858a5883cb7cd800e6fcd5803e158788"}, + "bunt": {:hex, :bunt, "0.2.1", "e2d4792f7bc0ced7583ab54922808919518d0e57ee162901a16a1b6664ef3b14", [:mix], [], "hexpm", "a330bfb4245239787b15005e66ae6845c9cd524a288f0d141c148b02603777a5"}, "castore": {:hex, :castore, "1.0.3", "7130ba6d24c8424014194676d608cb989f62ef8039efd50ff4b3f33286d06db8", [:mix], [], "hexpm", "680ab01ef5d15b161ed6a95449fac5c6b8f60055677a8e79acf01b27baa4390b"}, "certifi": {:hex, :certifi, "2.9.0", "6f2a475689dd47f19fb74334859d460a2dc4e3252a3324bd2111b8f0429e7e21", [:rebar3], [], "hexpm", "266da46bdb06d6c6d35fde799bcb28d36d985d424ad7c08b5bb48f5b5cdd4641"}, "chatterbox": {:hex, :ts_chatterbox, "0.13.0", "6f059d97bcaa758b8ea6fffe2b3b81362bd06b639d3ea2bb088335511d691ebf", [:rebar3], [{:hpack, "~>0.2.3", [hex: :hpack_erl, repo: "hexpm", optional: false]}], "hexpm", "b93d19104d86af0b3f2566c4cba2a57d2e06d103728246ba1ac6c3c0ff010aa7"}, @@ -7,6 +8,7 @@ "cowboy": {:hex, :cowboy, "2.10.0", "ff9ffeff91dae4ae270dd975642997afe2a1179d94b1887863e43f681a203e26", [:make, :rebar3], [{:cowlib, "2.12.1", [hex: :cowlib, repo: "hexpm", optional: false]}, {:ranch, "1.8.0", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm", "3afdccb7183cc6f143cb14d3cf51fa00e53db9ec80cdcd525482f5e99bc41d6b"}, "cowboy_telemetry": {:hex, :cowboy_telemetry, "0.4.0", "f239f68b588efa7707abce16a84d0d2acf3a0f50571f8bb7f56a15865aae820c", [:rebar3], [{:cowboy, "~> 2.7", [hex: :cowboy, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "7d98bac1ee4565d31b62d59f8823dfd8356a169e7fcbb83831b8a5397404c9de"}, "cowlib": {:hex, :cowlib, "2.12.1", "a9fa9a625f1d2025fe6b462cb865881329b5caff8f1854d1cbc9f9533f00e1e1", [:make, :rebar3], [], "hexpm", "163b73f6367a7341b33c794c4e88e7dbfe6498ac42dcd69ef44c5bc5507c8db0"}, + "credo": {:hex, :credo, "1.7.1", "6e26bbcc9e22eefbff7e43188e69924e78818e2fe6282487d0703652bc20fd62", [:mix], [{:bunt, "~> 0.2.1", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2.8", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "e9871c6095a4c0381c89b6aa98bc6260a8ba6addccf7f6a53da8849c748a58a2"}, "ctx": {:hex, :ctx, "0.6.0", "8ff88b70e6400c4df90142e7f130625b82086077a45364a78d208ed3ed53c7fe", [:rebar3], [], "hexpm", "a14ed2d1b67723dbebbe423b28d7615eb0bdcba6ff28f2d1f1b0a7e1d4aa5fc2"}, "db_connection": {:hex, :db_connection, "2.5.0", "bb6d4f30d35ded97b29fe80d8bd6f928a1912ca1ff110831edcd238a1973652c", [:mix], [{:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "c92d5ba26cd69ead1ff7582dbb860adeedfff39774105a4f1c92cbb654b55aa2"}, "decimal": {:hex, :decimal, "2.1.1", "5611dca5d4b2c3dd497dec8f68751f1f1a54755e8ed2a966c2633cf885973ad6", [:mix], [], "hexpm", "53cfe5f497ed0e7771ae1a475575603d77425099ba5faef9394932b35020ffcc"},