Skip to content

Commit

Permalink
--wip-- [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
vtm9 committed Nov 28, 2023
1 parent 445a037 commit 7198c21
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ export const connectToTournament = () => dispatch => {
const data = camelizeKeys(response);

dispatch(actions.updateTournamentMatches([data.match]));
dispatch(actions.updateTournamentPlayers(data.players));
};

const refs = [
Expand Down
6 changes: 4 additions & 2 deletions services/app/apps/codebattle/lib/codebattle/pub_sub/events.ex
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,13 @@ defmodule Codebattle.PubSub.Events do
end

def get_messages("tournament:match:upserted", params) do
players = Tournament.Helpers.get_plaeyrs(params.tournament, player_ids)

Enum.map(params.match.player_ids, fn player_id ->
%Message{
topic: "tournament:#{params.tournament_id}:player:#{player_id}",
topic: "tournament:#{params.tournament.id}:player:#{player_id}",
event: "tournament:match:upserted",
payload: %{match: params.match}
payload: %{match: params.match, players: players}
}
end)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ defmodule Codebattle.Tournament.Server do

defp broadcast_match_update(tournament, match) do
Codebattle.PubSub.broadcast("tournament:match:upserted", %{
tournament_id: tournament.id,
tournament: tournament,
match: match
})
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ defmodule Codebattle.Tournament.Base do
})

Codebattle.PubSub.broadcast("tournament:match:upserted", %{
tournament_id: tournament.id,
tournament: tournament,
match: match
})

Expand Down

0 comments on commit 7198c21

Please sign in to comment.