Skip to content

Commit

Permalink
Various bugfixes (#266)
Browse files Browse the repository at this point in the history
  • Loading branch information
evroon committed Sep 14, 2023
1 parent d1484a0 commit 33a1910
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 9 deletions.
39 changes: 39 additions & 0 deletions backend/alembic/versions/42683f6c1c45_remove_stages_status.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
"""remove stages.status
Revision ID: 42683f6c1c45
Revises: 3469289a7e06
Create Date: 2023-09-14 13:55:18.327147
"""

import sqlalchemy as sa
from sqlalchemy.dialects.postgresql import ENUM

from alembic import op

# revision identifiers, used by Alembic.
revision: str | None = '42683f6c1c45'
down_revision: str | None = '3469289a7e06'
branch_labels: str | None = None
depends_on: str | None = None


def upgrade() -> None:
op.drop_column('stages', 'status')


def downgrade() -> None:
op.add_column(
'stages',
sa.Column(
'status',
ENUM(
'COMPLETED',
'ACTIVE',
'INACTIVE',
name='stage_status',
create_type=True,
),
nullable=False,
),
)
4 changes: 2 additions & 2 deletions backend/bracket/models/db/stage.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@


class StageType(EnumAutoStr):
SINGLE_ELIMINATION = auto()
DOUBLE_ELIMINATION = auto()
ROUND_ROBIN = auto()
SINGLE_ELIMINATION = auto()
SWISS = auto()
SWISS_DYNAMIC_TEAMS = auto()
ROUND_ROBIN = auto()


class Stage(BaseModelORM):
Expand Down
7 changes: 5 additions & 2 deletions backend/bracket/sql/stages.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,9 @@ async def get_next_stage_in_tournament(
WHERE is_active IS TRUE
AND stages.tournament_id = :tournament_id
ORDER BY id ASC
LIMIT 1
),
-1
10000000000000
)
)
ELSE (
Expand All @@ -118,15 +119,17 @@ async def get_next_stage_in_tournament(
WHERE is_active IS TRUE
AND stages.tournament_id = :tournament_id
ORDER BY id DESC
LIMIT 1
),
-1
)
)
END
AND stages.tournament_id = :tournament_id
AND is_active IS FALSE
'''
return cast(
int,
int | None,
await database.execute(
query=select_query,
values={'tournament_id': tournament_id, 'direction': direction},
Expand Down
20 changes: 19 additions & 1 deletion frontend/src/components/brackets/brackets.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Alert, Grid, Skeleton } from '@mantine/core';
import { Alert, Container, Grid, Skeleton } from '@mantine/core';
import { IconAlertCircle } from '@tabler/icons-react';
import React from 'react';
import { SWRResponse } from 'swr';
Expand Down Expand Up @@ -48,6 +48,21 @@ function NoRoundsAlert({ readOnly }: { readOnly: boolean }) {
);
}

function NotStartedAlert() {
return (
<Container>
<Alert
icon={<IconAlertCircle size={16} />}
title="Tournament has not started yet"
color="blue"
radius="lg"
>
Please go to the next stage to start the tournament.
</Alert>
</Container>
);
}

function LoadingSkeleton() {
return (
<Grid>
Expand Down Expand Up @@ -76,6 +91,9 @@ export default function Brackets({
readOnly: boolean;
selectedStageId: number | null;
}) {
if (selectedStageId == null) {
return <NotStartedAlert />;
}
if (
selectedStageId == null ||
(!swrStagesResponse.isLoading && !responseIsValid(swrStagesResponse))
Expand Down
1 change: 0 additions & 1 deletion frontend/src/interfaces/stage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export interface StageWithRounds {
created: string;
type: string;
type_name: string;
status: string;
is_active: boolean;
rounds: RoundInterface[];
}
18 changes: 15 additions & 3 deletions frontend/src/pages/tournaments/[id]/settings.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
import { Button, Checkbox, Container, CopyButton, Image, Select, TextInput } from '@mantine/core';
import {
Button,
Center,
Checkbox,
Container,
CopyButton,
Image,
Select,
TextInput,
} from '@mantine/core';
import { useForm } from '@mantine/form';
import assert from 'assert';
import { SWRResponse } from 'swr';
Expand Down Expand Up @@ -102,8 +111,11 @@ function GeneralTournamentForm({

{tournament != null ? <DropzoneButton tournament={tournament} /> : null}

<TournamentLogo tournament={tournament} />
<Button fullWidth mt={8} color="green" type="submit">
<Center maw="50%" mx="auto">
<TournamentLogo tournament={tournament} />
</Center>

<Button fullWidth mt={24} color="green" type="submit">
Save
</Button>

Expand Down
1 change: 1 addition & 0 deletions frontend/src/pages/tournaments/[id]/stages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ function CreateStageForm(tournament: Tournament, swrClubsResponse: SWRResponse)
{ value: 'ROUND_ROBIN', label: 'Round Robin' },
{ value: 'SINGLE_ELIMINATION', label: 'Single Elimination' },
{ value: 'DOUBLE_ELIMINATION', label: 'Double Elimination' },
{ value: 'SWISS', label: 'Swiss' },
]}
{...form.getInputProps('type')}
/>
Expand Down

1 comment on commit 33a1910

@vercel
Copy link

@vercel vercel bot commented on 33a1910 Sep 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.