Skip to content

Commit 15a5147

Browse files
committed
Top 200 history
1 parent 146cc99 commit 15a5147

File tree

13 files changed

+1129
-701
lines changed

13 files changed

+1129
-701
lines changed

services/app/apps/codebattle/lib/codebattle/tournament/helpers.ex

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,7 @@ defmodule Codebattle.Tournament.Helpers do
369369

370370
top_8_ids = total_ranking |> Enum.take(8) |> Enum.map(& &1.id)
371371
user_history = Tournament.TournamentResult.get_users_history(tournament, top_8_ids)
372+
max_draw_index = players |> Enum.map(& &1.draw_index) |> Enum.max()
372373

373374
%{
374375
"tournament_id" => tournament.id,
@@ -383,10 +384,11 @@ defmodule Codebattle.Tournament.Helpers do
383384
"total_score" => player.score,
384385
"total_tasks" => Enum.count(player.matches_ids),
385386
"won_tasks" => player.wins_count,
386-
"rank" => player.rank,
387+
"rank" => player.place,
387388
# TODO: do win_prob based on the top 8 people
388389
"win_prob" => "42",
389-
"active" => if(player.in_main_draw, do: 1, else: 0),
390+
"returned" => if(player.returned, do: 1, else: 0),
391+
"active" => if(player.draw_index == max_draw_index, do: 1, else: 0),
390392
"history" => user_history[player.id] || []
391393
}
392394
end)

services/app/apps/codebattle/lib/codebattle/tournament/player.ex

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ defmodule Codebattle.Tournament.Player do
2424
:rating,
2525
:score,
2626
:team_id,
27-
:in_main_draw,
27+
:draw_index,
2828
:wr_joined_at,
2929
:wins_count
3030
]
@@ -44,13 +44,14 @@ defmodule Codebattle.Tournament.Player do
4444
field(:clan_id, :integer)
4545
field(:id, :integer)
4646
field(:is_bot, :boolean)
47-
field(:in_main_draw, :boolean, default: true)
47+
field(:draw_index, :integer, default: 1)
4848
field(:lang, :string)
4949
field(:matches_ids, {:array, :integer}, default: [])
5050
field(:name, :string)
5151
field(:place, :integer, default: 0)
5252
field(:rank, :integer, default: 5432)
5353
field(:rating, :integer)
54+
field(:returned, :boolean, default: false)
5455
field(:score, :integer, default: 0)
5556
field(:state, :string, default: "active")
5657
field(:task_ids, {:array, :integer}, default: [])

services/app/apps/codebattle/lib/codebattle/tournament/storage/players.ex

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,4 @@ defmodule Codebattle.Tournament.Players do
4545
get_player(tournament, player_id)
4646
end)
4747
end
48-
49-
def move_players_from_main_draw(tournament, player_ids) do
50-
Enum.each(player_ids, fn player_id ->
51-
tournament
52-
|> get_player(player_id)
53-
|> Map.put(:in_main_draw, false)
54-
|> then(&put_player(tournament, &1))
55-
end)
56-
end
5748
end

0 commit comments

Comments
 (0)