Skip to content

Commit 085df6e

Browse files
committed
bug: fix showing ability to veto when should not be able to
1 parent 711c7de commit 085df6e

4 files changed

Lines changed: 18 additions & 7 deletions

File tree

hasura/functions/match/lineups/is_captain.sql

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,19 @@ BEGIN
1414
);
1515
END;
1616
$$;
17+
18+
CREATE OR REPLACE FUNCTION public.is_captain_on_lineup(match_lineup public.match_lineups, hasura_session json)
19+
RETURNS boolean
20+
LANGUAGE plpgsql STABLE
21+
AS $$
22+
DECLARE
23+
BEGIN
24+
RETURN EXISTS (
25+
SELECT 1
26+
FROM match_lineup_players mlp
27+
WHERE mlp.match_lineup_id = match_lineup.id
28+
AND mlp.steam_id = (hasura_session ->> 'x-hasura-user-id')::bigint
29+
and mlp.captain = true
30+
);
31+
END;
32+
$$;

hasura/functions/match/lineups/is_in_lineup.sql

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@ CREATE OR REPLACE FUNCTION public.is_in_lineup(match public.matches, hasura_sess
33
AS $$
44
DECLARE
55
BEGIN
6-
7-
IF(hasura_session ->> 'x-hasura-role' = 'admin') THEN
8-
RETURN true;
9-
END IF;
10-
116
RETURN EXISTS (
127
SELECT 1
138
FROM match_lineups ml

hasura/functions/match/map-veto/can_pick_map_veto.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ CREATE OR REPLACE FUNCTION public.can_pick_map_veto(match_lineup public.match_li
33
AS $$
44
DECLARE
55
BEGIN
6-
IF lineup_is_picking_map_veto(match_lineup) AND is_on_lineup(match_lineup, hasura_session) THEN
6+
IF lineup_is_picking_map_veto(match_lineup) AND is_captain_on_lineup(match_lineup, hasura_session) THEN
77
return true;
88
END IF;
99

hasura/functions/match/region-veto/can_pick_region_veto.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ CREATE OR REPLACE FUNCTION public.can_pick_region_veto(match_lineup public.match
33
AS $$
44
DECLARE
55
BEGIN
6-
IF lineup_is_picking_region_veto(match_lineup) AND is_on_lineup(match_lineup, hasura_session) THEN
6+
IF lineup_is_picking_region_veto(match_lineup) AND is_captain_on_lineup(match_lineup, hasura_session) THEN
77
return true;
88
END IF;
99

0 commit comments

Comments
 (0)