Skip to content

Commit

Permalink
Remove unnecessary data loading and passing in host control panel
Browse files Browse the repository at this point in the history
We used to display this stuff but I change the display.
  • Loading branch information
bakert committed Dec 5, 2024
1 parent e79b98d commit e66dbfa
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 23 deletions.
8 changes: 4 additions & 4 deletions gatherling/Views/Components/HostEvents.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@

class HostEvents extends Component
{
/** @var list<array{name: string, format: string, players: int, host: string, start: string, active: int, finalized: int, cohost: string, series: string, kvalueDisplay: string, link: string, isOngoing: bool, currentRound: int, settingsLink: string, registrationLink: string, matchesLink: string, standingsLink: string, structureSummary: string, startTime: Time}> */
/** @var list<array{name: string, players: int, start: string, active: int, finalized: int, series: string, link: string, currentRound: int, settingsLink: string, registrationLink: string, matchesLink: string, standingsLink: string, structureSummary: string, startTime: Time}> */
public array $pendingEvents = [];
/** @var list<array{name: string, format: string, players: int, host: string, start: string, active: int, finalized: int, cohost: string, series: string, kvalueDisplay: string, link: string, isOngoing: bool, currentRound: int, settingsLink: string, registrationLink: string, matchesLink: string, standingsLink: string, structureSummary: string, startTime: Time}> */
/** @var list<array{name: string, players: int, start: string, active: int, finalized: int, series: string, link: string, currentRound: int, settingsLink: string, registrationLink: string, matchesLink: string, standingsLink: string, structureSummary: string, startTime: Time}> */
public array $activeEvents = [];

public bool $hasPendingEvents;
public bool $hasActiveEvents;

/**
* @param list<array{name: string, format: string, players: int, host: string, start: string, active: int, finalized: int, cohost: string, series: string, kvalueDisplay: string, link: string, isOngoing: bool, currentRound: int, settingsLink: string, registrationLink: string, matchesLink: string, standingsLink: string, structureSummary: string}> $pendingEvents
* @param list<array{name: string, format: string, players: int, host: string, start: string, active: int, finalized: int, cohost: string, series: string, kvalueDisplay: string, link: string, isOngoing: bool, currentRound: int, settingsLink: string, registrationLink: string, matchesLink: string, standingsLink: string, structureSummary: string}> $activeEvents
* @param list<array{name: string, players: int, start: string, active: int, finalized: int, series: string, link: string, currentRound: int, settingsLink: string, registrationLink: string, matchesLink: string, standingsLink: string, structureSummary: string}> $pendingEvents
* @param list<array{name: string, players: int, start: string, active: int, finalized: int, series: string, link: string, currentRound: int, settingsLink: string, registrationLink: string, matchesLink: string, standingsLink: string, structureSummary: string}> $activeEvents
*/
public function __construct(array $pendingEvents, array $activeEvents)
{
Expand Down
22 changes: 4 additions & 18 deletions gatherling/Views/Pages/EventList.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
use Gatherling\Views\Components\HostEvents;
use Gatherling\Views\Components\SeasonDropMenu;
use Gatherling\Views\Components\SeriesDropMenu;
use Gatherling\Views\Components\Time;

use function Gatherling\Helpers\db;
use function Gatherling\Helpers\get;
Expand All @@ -24,9 +23,9 @@ class EventList extends Page
public SeriesDropMenu $seriesDropMenu;
public SeasonDropMenu $seasonDropMenu;
public bool $hasPlayerSeries;
/** @var list<array{name: string, format: string, players: int, host: string, start: string, active: int, finalized: int, cohost: string, series: string, kvalueDisplay: string, link: string, isOngoing: bool, currentRound: int, settingsLink: string, registrationLink: string, matchesLink: string, standingsLink: string, structureSummary: string}> */
/** @var list<array{name: string, players: int, start: string, active: int, finalized: int, series: string, link: string, currentRound: int, settingsLink: string, registrationLink: string, matchesLink: string, standingsLink: string, structureSummary: string}> */
public array $upcomingEvents;
/** @var list<array{name: string, format: string, players: int, host: string, start: string, active: int, finalized: int, cohost: string, series: string, kvalueDisplay: string, link: string, isOngoing: bool, currentRound: int, settingsLink: string, registrationLink: string, matchesLink: string, standingsLink: string, structureSummary: string}> */
/** @var list<array{name: string, players: int, start: string, active: int, finalized: int, series: string, link: string, currentRound: int, settingsLink: string, registrationLink: string, matchesLink: string, standingsLink: string, structureSummary: string}> */
public array $pastEvents;
public bool $hasMore;

Expand All @@ -39,31 +38,18 @@ public function __construct(string $seriesName, string $format, ?int $season)
$events = queryEvents($player, $playerSeries, $seriesName, $format, $season);
$hasMore = count($events) == 100;

$kvalueMap = [
0 => 'none',
8 => 'Casual',
16 => 'Regular',
24 => 'Large',
32 => 'Championship',
];

$pendingEvents = $activeEvents = $upcomingEvents = $pastEvents = $seriesShown = [];
foreach ($events as $event) {
$seriesShown[] = $event->series;
$baseLink = 'event.php?name=' . rawurlencode($event->name) . '&view=';
$eventInfo = [
'name' => $event->name,
'format' => $event->format,
'players' => $event->players,
'host' => $event->host,
'start' => $event->start,
'active' => $event->active,
'finalized' => $event->finalized,
'cohost' => $event->cohost ?? '',
'series' => $event->series,
'kvalueDisplay' => $kvalueMap[$event->kvalue] ?? '',
'link' => 'event.php?name=' . rawurlencode($event->name),
'isOngoing' => $event->finalized == 0 && $event->active == 1,
'currentRound' => $event->current_round,
'settingsLink' => "{$baseLink}settings",
'registrationLink' => "{$baseLink}reg",
Expand Down Expand Up @@ -106,8 +92,8 @@ public function __construct(string $seriesName, string $format, ?int $season)
function queryEvents(Player $player, array $playerSeries, string $seriesName, string $format, ?int $season): array
{
$sql = '
SELECT e.name, e.format, COUNT(DISTINCT n.player) AS players, e.host, e.start,
e.active, e.finalized, e.cohost, e.series, e.kvalue, e.current_round
SELECT e.name, COUNT(DISTINCT n.player) AS players, e.start, e.active,
e.finalized, e.series, e.current_round
FROM events e
LEFT JOIN entries AS n ON n.event_id = e.id
WHERE (e.host = :player_name OR e.cohost = :player_name OR e.series IN (:series_names))';
Expand Down
1 change: 0 additions & 1 deletion gatherling/templates/eventList.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@
</tr>
{{#pastEvents}}
<tr>
<!-- BAKERT scratch host, cohost, isOngoging, kvalueDisplay, format, spllit itnno two buckets -->
<td><a href="{{link}}">{{name}}</a></td>
<td class="c">{{players}}</td>
</tr>
Expand Down

0 comments on commit e66dbfa

Please sign in to comment.