@@ -3,16 +3,14 @@ defmodule Codebattle.Tournament.Helpers do
33 alias Codebattle.Tournament
44 alias Codebattle.User
55
6- def get_player ( % { players_table: nil } = tournament , id ) ,
7- do: Map . get ( tournament . players , to_id ( id ) )
6+ def get_player ( % { players_table: nil } = tournament , id ) , do: Map . get ( tournament . players , to_id ( id ) )
87
98 def get_player ( tournament , id ) , do: Tournament.Players . get_player ( tournament , id )
109
1110 def get_players ( % { players_table: nil } = tournament ) , do: Map . values ( tournament . players )
1211 def get_players ( tournament ) , do: Tournament.Players . get_players ( tournament )
1312
14- def get_players ( % { players_table: nil } = tournament , ids ) ,
15- do: Enum . map ( ids , & get_player ( tournament , & 1 ) )
13+ def get_players ( % { players_table: nil } = tournament , ids ) , do: Enum . map ( ids , & get_player ( tournament , & 1 ) )
1614
1715 def get_players ( tournament , ids ) , do: Tournament.Players . get_players ( tournament , ids )
1816
@@ -42,23 +40,20 @@ defmodule Codebattle.Tournament.Helpers do
4240 |> Enum . slice ( start_index .. end_index )
4341 end
4442
45- def get_match ( % { matches_table: nil } = tournament , id ) ,
46- do: Map . get ( tournament . matches , to_id ( id ) )
43+ def get_match ( % { matches_table: nil } = tournament , id ) , do: Map . get ( tournament . matches , to_id ( id ) )
4744
4845 def get_match ( tournament , id ) , do: Tournament.Matches . get_match ( tournament , id )
4946
5047 def get_matches ( % { matches_table: nil } = tournament ) , do: Map . values ( tournament . matches )
5148 def get_matches ( tournament ) , do: Tournament.Matches . get_matches ( tournament )
5249
53- def get_matches ( tournament , ids ) when is_list ( ids ) ,
54- do: Enum . map ( ids , & get_match ( tournament , & 1 ) )
50+ def get_matches ( tournament , ids ) when is_list ( ids ) , do: Enum . map ( ids , & get_match ( tournament , & 1 ) )
5551
5652 def get_matches ( tournament , state ) when is_binary ( state ) do
5753 tournament |> get_matches ( ) |> Enum . filter ( & ( & 1 . state == state ) )
5854 end
5955
60- def get_matches ( tournament , ids_or_state ) ,
61- do: Tournament.Matches . get_matches ( tournament , ids_or_state )
56+ def get_matches ( tournament , ids_or_state ) , do: Tournament.Matches . get_matches ( tournament , ids_or_state )
6257
6358 def get_matches_by_players ( tournament , player_ids ) do
6459 matches_ids =
@@ -126,9 +121,7 @@ defmodule Codebattle.Tournament.Helpers do
126121 def get_current_round_playing_matches ( tournament ) do
127122 tournament
128123 |> get_matches ( )
129- |> Enum . filter (
130- & ( & 1 . round_position == tournament . current_round_position and & 1 . state == "playing" )
131- )
124+ |> Enum . filter ( & ( & 1 . round_position == tournament . current_round_position and & 1 . state == "playing" ) )
132125 end
133126
134127 def match_player? ( match , player_id ) , do: Enum . any? ( match . player_ids , & ( & 1 == player_id ) )
@@ -317,10 +310,7 @@ defmodule Codebattle.Tournament.Helpers do
317310 ] )
318311 end
319312
320- def get_players_total_games_count (
321- % { task_provider: "task_pack" , task_strategy: "sequential" } = t ,
322- _player
323- ) do
313+ def get_players_total_games_count ( % { task_provider: "task_pack" , task_strategy: "sequential" } = t , _player ) do
324314 t |> Tournament.Tasks . get_task_ids ( ) |> Enum . count ( )
325315 end
326316
0 commit comments