-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/Add ranking information to profile (#195)
* Create user_ranking function that returns user scores per each category. * Create user_ranking action that responds with user scores for each category. * Create User Scores panel in Profile section. * Elm formatter
- Loading branch information
Showing
14 changed files
with
224 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ defmodule Aion.RankingTest do | |
@user1_attrs %{name: "John", email: "[email protected]", password: "test123"} | ||
@user2_attrs %{name: "Michael", email: "[email protected]", password: "test123"} | ||
|
||
describe "Ranking.data" do | ||
describe "Ranking.general_ranking/0" do | ||
test "returns player scores for each category" do | ||
user1 = Repo.insert! User.registration_changeset(%User{}, @user1_attrs) | ||
user2 = Repo.insert! User.registration_changeset(%User{}, @user2_attrs) | ||
|
@@ -15,10 +15,25 @@ defmodule Aion.RankingTest do | |
Repo.insert! %UserCategoryScore{user: user1, category: category2, score: 4} | ||
Repo.insert! %UserCategoryScore{user: user2, category: category2, score: 5} | ||
|
||
result = Ranking.data() | ||
result = Ranking.general_ranking() | ||
|
||
assert result == [%{category_id: category1.id, category_name: "category1", scores: [%{user_name: "John", score: 2}]}, | ||
%{category_id: category2.id, category_name: "category2", scores: [%{user_name: "John", score: 4}, %{user_name: "Michael", score: 5}]}] | ||
end | ||
end | ||
|
||
describe "Ranking.user_ranking/1" do | ||
test "returns user scores for each category" do | ||
user1 = Repo.insert! User.registration_changeset(%User{}, @user1_attrs) | ||
category1 = Repo.insert! %Category{name: "category1"} | ||
category2 = Repo.insert! %Category{name: "category2"} | ||
Repo.insert! %UserCategoryScore{user: user1, category: category1, score: 2} | ||
Repo.insert! %UserCategoryScore{user: user1, category: category2, score: 4} | ||
|
||
result = Ranking.user_ranking(user1.id) | ||
|
||
assert result == [%{category_id: category1.id, category_name: "category1", score: 2}, | ||
%{category_id: category2.id, category_name: "category2", score: 4}] | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,26 @@ | ||
module User.Models exposing (..) | ||
|
||
import RemoteData exposing (WebData) | ||
|
||
|
||
type alias UserData = | ||
{ details : WebData CurrentUser | ||
, scores : WebData UserScores | ||
} | ||
|
||
|
||
type alias CurrentUser = | ||
{ name : String | ||
, id : Int | ||
, email : String | ||
} | ||
|
||
|
||
type alias UserScores = | ||
{ categoryScores : List UserCategoryScore } | ||
|
||
|
||
type alias UserCategoryScore = | ||
{ categoryName : String | ||
, score : Int | ||
} |
Oops, something went wrong.