Skip to content

Commit 6597a3e

Browse files
committed
Ran Mix Format
1 parent 0a4cdb3 commit 6597a3e

File tree

6 files changed

+24
-13
lines changed

6 files changed

+24
-13
lines changed

lib/cadet/accounts/game_states.ex

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ defmodule Cadet.GameStates do
1818

1919
def update(user, new_game_states) do
2020
if user.role == :student do
21-
changeset =
22-
Ecto.Changeset.cast(user, %{game_states:
23-
new_game_states},[:game_states])
21+
changeset = Ecto.Changeset.cast(user, %{game_states: new_game_states}, [:game_states])
2422
Cadet.Repo.update!(changeset)
2523
{:ok, nil}
2624
else
@@ -31,8 +29,10 @@ defmodule Cadet.GameStates do
3129
def clear(user) do
3230
if user.role == :student do
3331
changeset =
34-
Ecto.Changeset.cast(user, %{game_states: %{collectibles: %{},
35-
completed_quests: []}},[:game_states])
32+
Ecto.Changeset.cast(user, %{game_states: %{collectibles: %{}, completed_quests: []}}, [
33+
:game_states
34+
])
35+
3636
Cadet.Repo.update!(changeset)
3737
{:ok, nil}
3838
else

lib/cadet_web/controllers/user_controller.ex

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ defmodule CadetWeb.UserController do
1616
story = user_current_story(user)
1717
xp = user_total_xp(user)
1818
game_states = user_game_states(user)
19+
1920
render(
2021
conn,
2122
"index.json",
@@ -39,6 +40,7 @@ defmodule CadetWeb.UserController do
3940

4041
def update_game_states(conn, %{"gameStates" => new_game_states}) do
4142
user = conn.assigns[:current_user]
43+
4244
case Cadet.GameStates.update(user, new_game_states) do
4345
{:ok, nil} ->
4446
text(conn, "OK")
@@ -56,9 +58,11 @@ defmodule CadetWeb.UserController do
5658
security([%{JWT: []}])
5759
consumes("application/json")
5860
produces("application/json")
61+
5962
parameters do
6063
new_game_states(:path, :map, "new game states", required: true)
6164
end
65+
6266
response(200, "OK", Schema.ref(:UserInfo))
6367
response(201, "Created")
6468
response(204, "No Content")
@@ -68,9 +72,11 @@ defmodule CadetWeb.UserController do
6872

6973
def clear_up_game_states(conn, _) do
7074
user = conn.assigns[:current_user]
75+
7176
case Cadet.GameStates.clear(user) do
7277
{:ok, nil} ->
7378
text(conn, "OK")
79+
7480
{:error, {status, message}} ->
7581
conn
7682
|> put_status(status)
@@ -90,7 +96,6 @@ defmodule CadetWeb.UserController do
9096
response(401, "Unauthorised")
9197
end
9298

93-
9499
def swagger_definitions do
95100
%{
96101
UserInfo:
@@ -128,10 +133,9 @@ defmodule CadetWeb.UserController do
128133

129134
game_states(
130135
:map,
131-
"States for user's game, including users' collectibles and completed quests.\n"
132-
<> "Collectibles is a map.\n"
133-
<> "Completed quests is an array of strings"
134-
136+
"States for user's game, including users' collectibles and completed quests.\n" <>
137+
"Collectibles is a map.\n" <>
138+
"Completed quests is an array of strings"
135139
)
136140
end
137141
end,

lib/cadet_web/router.ex

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,10 @@ defmodule CadetWeb.Router do
5353
get("/notification", NotificationController, :index)
5454
post("/notification/acknowledge", NotificationController, :acknowledge)
5555

56-
5756
get("/user", UserController, :index)
5857
put("/user/game_states/clear", UserController, :clear_up_game_states)
5958
put("/user/game_states/save", UserController, :update_game_states)
6059

61-
6260
post("/chat/token", ChatController, :index)
6361
post("/chat/notify", ChatController, :notify)
6462
end

lib/cadet_web/views/user_view.ex

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
defmodule CadetWeb.UserView do
22
use CadetWeb, :view
33

4-
def render("index.json", %{user: user, grade: grade, max_grade: max_grade, xp: xp, story: story, game_states: game_states}) do
4+
def render("index.json", %{
5+
user: user,
6+
grade: grade,
7+
max_grade: max_grade,
8+
xp: xp,
9+
story: story,
10+
game_states: game_states
11+
}) do
512
%{
613
name: user.name,
714
role: user.role,

priv/repo/migrations/20200410074625_add_game_states.exs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
defmodule Cadet.Repo.Migrations.AddGameStates do
22
use Ecto.Migration
3+
34
def change do
45
alter table(:users) do
56
add(:game_states, :map, default: %{collectibles: %{}, completed_quests: []})

test/cadet/updater/xml_parser_test.exs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ defmodule Cadet.Updater.XMLParserTest do
99
import ExUnit.CaptureLog
1010

1111
@local_name "test/fixtures/local_repo"
12+
1213
# @locations %{mission: "missions", sidequest: "quests", path: "paths", contest: "contests"}
1314

1415
setup do

0 commit comments

Comments
 (0)