Skip to content

Commit b1da20f

Browse files
committed
bug: let game server decides won won
1 parent b69b141 commit b1da20f

3 files changed

Lines changed: 7 additions & 39 deletions

File tree

hasura/functions/match/maps/match_map_winner.sql

Lines changed: 0 additions & 36 deletions
This file was deleted.

hasura/triggers/match_maps.sql

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ BEGIN
4242

4343
IF NEW.status = 'Finished' THEN
4444
NEW.ended_at = NOW();
45-
46-
NEW.winning_lineup_id = get_match_map_winning_lineup_id(NEW);
4745
END IF;
4846

4947
RETURN NEW;

src/matches/events/MatchMapStatusEvent.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { e_match_map_status_enum } from "../../../generated";
33

44
export default class MatchMapStatusEvent extends MatchEventProcessor<{
55
status: e_match_map_status_enum;
6+
winning_lineup_id?: string;
67
}> {
78
public async process() {
89
const { matches_by_pk: match } = await this.hasura.query({
@@ -18,6 +19,8 @@ export default class MatchMapStatusEvent extends MatchEventProcessor<{
1819
return;
1920
}
2021

22+
const isFinished = this.data.status === "Finished";
23+
2124
const { update_match_maps_by_pk } = await this.hasura.mutation({
2225
update_match_maps_by_pk: {
2326
__args: {
@@ -26,6 +29,9 @@ export default class MatchMapStatusEvent extends MatchEventProcessor<{
2629
},
2730
_set: {
2831
status: this.data.status,
32+
...(isFinished
33+
? { winning_lineup_id: this.data.winning_lineup_id }
34+
: {}),
2935
},
3036
},
3137
id: true,
@@ -35,7 +41,7 @@ export default class MatchMapStatusEvent extends MatchEventProcessor<{
3541
},
3642
});
3743

38-
if (this.data.status === "Finished") {
44+
if (isFinished) {
3945
if (update_match_maps_by_pk.match.current_match_map_id !== null) {
4046
await this.matchAssistant.sendServerMatchId(this.matchId);
4147
return;

0 commit comments

Comments
 (0)