File tree Expand file tree Collapse file tree 3 files changed +11
-18
lines changed
services/app/apps/codebattle/lib Expand file tree Collapse file tree 3 files changed +11
-18
lines changed Original file line number Diff line number Diff line change @@ -239,12 +239,16 @@ defmodule Codebattle.Tournament.Helpers do
239239 # end
240240
241241 def get_active_game_id ( tournament , player_id ) do
242- tournament
243- |> get_matches ( "playing" )
244- |> Enum . find ( fn match -> player_id in match . player_ids end )
245- |> case do
246- nil -> nil
247- match -> match . game_id
242+ player = get_player ( tournament , player_id )
243+ match_id = List . last ( player . matches_ids )
244+
245+ if match_id do
246+ tournament
247+ |> get_match ( match_id )
248+ |> case do
249+ % { state: "playing" } -> match_id
250+ _ -> nil
251+ end
248252 end
249253 end
250254
Original file line number Diff line number Diff line change @@ -35,13 +35,6 @@ defmodule Codebattle.Tournament.Base do
3535
3636 require Logger
3737
38- @ custom_round_tiemouts_in_sec % {
39- "elementary" => 5 * 60 ,
40- "easy" => 6 * 60 ,
41- "medium" => 10 * 60 ,
42- "hard" => 25 * 60
43- }
44-
4538 def add_player ( tournament , player ) do
4639 tournament_player = Tournament.Player . new! ( player )
4740 Tournament.Players . put_player ( tournament , tournament_player )
@@ -967,11 +960,8 @@ defmodule Codebattle.Tournament.Base do
967960 end
968961 end
969962
970- defp get_custom_round_timeout_seconds ( tournament , nil ) , do: get_round_timeout_seconds ( tournament )
971-
972963 defp get_custom_round_timeout_seconds ( tournament , task ) do
973- Map . get ( @ custom_round_tiemouts_in_sec , task . level ) ||
974- get_round_timeout_seconds ( tournament )
964+ ( task && task . time_to_solve_sec ) || get_round_timeout_seconds ( tournament )
975965 end
976966
977967 defp seconds_to_end_round ( tournament ) do
Original file line number Diff line number Diff line change @@ -25,7 +25,6 @@ defmodule CodebattleWeb.GameChannel do
2525
2626 active_game_id = Tournament.Helpers . get_active_game_id ( tournament , user_id )
2727
28- # TODO: think about active_game_id
2928 { user_id , active_game_id }
3029 else
3130 { nil , nil }
You can’t perform that action at this time.
0 commit comments