Skip to content

Commit 7d2e7ad

Browse files
authored
Merge branch 'master' into v2
2 parents 7e8533d + 9363a7a commit 7d2e7ad

File tree

11 files changed

+44
-37
lines changed

11 files changed

+44
-37
lines changed

lib/cadet_web/admin_controllers/admin_achievements_controller.ex

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,18 @@ defmodule CadetWeb.AdminAchievementsController do
3131
|> snake_casify_string_keys_recursive()
3232
|> rename_keys([
3333
{"deadline", "close_at"},
34-
{"release", "open_at"}
34+
{"release", "open_at"},
35+
{"card_background", "card_tile_url"}
3536
])
3637
|> case do
3738
map = %{"view" => view} ->
3839
map
3940
|> Map.delete("view")
40-
|> Map.merge(view |> Map.take(~w(canvas_url description completion_text)))
41+
|> Map.merge(
42+
view
43+
|> rename_keys([{"cover_image", "canvas_url"}])
44+
|> Map.take(~w(canvas_url description completion_text))
45+
)
4146

4247
map ->
4348
map

lib/cadet_web/admin_controllers/admin_goals_controller.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ defmodule CadetWeb.AdminGoalsController do
3030
end
3131

3232
defp json_to_goal(json, uuid \\ nil) do
33+
original_meta = json["meta"]
34+
3335
json =
3436
json
3537
|> snake_casify_string_keys_recursive()
36-
|> rename_keys([
37-
{"max_exp", "max_xp"}
38-
])
38+
|> Map.put("meta", original_meta)
3939

4040
if is_nil(uuid) do
4141
json

lib/cadet_web/admin_views/admin_goals_view.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ defmodule CadetWeb.AdminGoalsView do
1010
transform_map_for_view(goal, %{
1111
uuid: :uuid,
1212
text: :text,
13-
maxExp: :max_xp,
13+
maxXp: :max_xp,
1414
type: :type,
1515
meta: :meta
1616
})

lib/cadet_web/controllers/incentives_controller.ex

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ defmodule CadetWeb.IncentivesController do
5858
"Achievement ability i.e. category"
5959
)
6060

61-
cardTileUrl(
61+
cardBackground(
6262
:string,
6363
"URL of the achievement's background image"
6464
)
@@ -104,7 +104,7 @@ defmodule CadetWeb.IncentivesController do
104104
description("Achievement view properties")
105105

106106
properties do
107-
canvasUrl(
107+
coverImage(
108108
:string,
109109
"URL of the image for the view"
110110
)
@@ -136,7 +136,7 @@ defmodule CadetWeb.IncentivesController do
136136
"Text to show when goal is completed"
137137
)
138138

139-
maxExp(
139+
maxXp(
140140
:integer,
141141
"Total EXP for this goal"
142142
)
@@ -173,12 +173,12 @@ defmodule CadetWeb.IncentivesController do
173173
"Text to show when goal is completed"
174174
)
175175

176-
exp(
176+
xp(
177177
:integer,
178178
"EXP currently attained by the user for this goal"
179179
)
180180

181-
maxExp(
181+
maxXp(
182182
:integer,
183183
"Total EXP for this goal"
184184
)

lib/cadet_web/views/incentives_view.ex

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@ defmodule CadetWeb.IncentivesView do
1414
release: &format_datetime(&1.open_at),
1515
deadline: &format_datetime(&1.close_at),
1616
isTask: :is_task,
17-
prerequisiteIds:
18-
&Enum.map(&1.prerequisites, fn prerequisite -> prerequisite.prerequisite_id end),
19-
cardTileUrl: :card_tile_url,
17+
prerequisiteUuids:
18+
&Enum.map(&1.prerequisites, fn prerequisite -> prerequisite.prerequisite_uuid end),
19+
cardBackground: :card_tile_url,
2020
position: :position,
2121
view:
2222
&%{
23-
canvasUrl: &1.canvas_url,
23+
coverImage: &1.canvas_url,
2424
description: &1.description,
2525
completionText: &1.completion_text
2626
},
27-
goalUuids: &Enum.map(&1.goals, fn goal -> goal.uuid end)
27+
goalUuids: &Enum.map(&1.goals, fn goal -> goal.goal_uuid end)
2828
})
2929
end
3030

@@ -36,15 +36,15 @@ defmodule CadetWeb.IncentivesView do
3636
transform_map_for_view(goal, %{
3737
uuid: :uuid,
3838
text: :text,
39-
exp: fn
39+
xp: fn
4040
%{progress: [%{xp: xp}]} -> xp
4141
_ -> 0
4242
end,
4343
completed: fn
4444
%{progress: [%{completed: completed}]} -> completed
4545
_ -> false
4646
end,
47-
maxExp: :max_xp,
47+
maxXp: :max_xp,
4848
type: :type,
4949
meta: :meta
5050
})

mix.exs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ defmodule Cadet.Mixfile do
5757
{:ex_aws_s3, "~> 2.0"},
5858
{:ex_aws_secretsmanager, "~> 2.0"},
5959
{:ex_aws_sts, "~> 2.1"},
60+
{:ex_json_schema, "~> 0.7.4"},
6061
{:ex_machina, "~> 2.3"},
6162
{:guardian, "~> 2.0"},
6263
{:guardian_db, "~> 2.0"},

mix.lock

Lines changed: 13 additions & 12 deletions
Large diffs are not rendered by default.

test/cadet_web/controllers/incentives_controller_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ defmodule CadetWeb.IncentivesControllerTest do
5555
[resp_goal] = conn |> get("/v1/self/goals") |> json_response(200)
5656

5757
assert goal_json_literal(0) = resp_goal
58-
assert resp_goal["exp"] == progress.xp
58+
assert resp_goal["xp"] == progress.xp
5959
assert resp_goal["completed"] == progress.completed
6060
end
6161

test/fixtures/vcr_cassettes/aws/controller_list_assets#1.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"recv_timeout": 660000
1515
},
1616
"request_body": "",
17-
"url": "https://s3.ap-southeast-1.amazonaws.com/source-academy-assets/"
17+
"url": "https://s3.ap-southeast-1.amazonaws.com/source-academy-assets"
1818
},
1919
"response": {
2020
"binary": false,
@@ -30,4 +30,4 @@
3030
"type": "ok"
3131
}
3232
}
33-
]
33+
]

test/fixtures/vcr_cassettes/aws/model_list_assets#1.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"recv_timeout": 660000
1515
},
1616
"request_body": "",
17-
"url": "https://s3.ap-southeast-1.amazonaws.com/source-academy-assets/"
17+
"url": "https://s3.ap-southeast-1.amazonaws.com/source-academy-assets"
1818
},
1919
"response": {
2020
"binary": false,

test/support/test_entity_helper.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ defmodule Cadet.TestEntityHelper do
2121
"ability" => "Core",
2222
"position" => id,
2323
"title" => "Achievement #{id}",
24-
"cardTileUrl" => "http://hello#{id}",
24+
"cardBackground" => "http://hello#{id}",
2525
"isTask" => false,
2626
"view" => %{
27-
"canvasUrl" => "http://bye#{id}",
27+
"coverImage" => "http://bye#{id}",
2828
"completionText" => "Done #{id}",
2929
"description" => "Test #{id}"
3030
}
@@ -42,7 +42,7 @@ defmodule Cadet.TestEntityHelper do
4242

4343
defmacro goal_json_literal(id) do
4444
Macro.escape(%{
45-
"maxExp" => id,
45+
"maxXp" => id,
4646
"meta" => %{"id" => id},
4747
"text" => "Sample #{id}",
4848
"type" => "type_#{id}"

0 commit comments

Comments
 (0)