Skip to content

Commit

Permalink
Also renamed the misspelling
Browse files Browse the repository at this point in the history
This is always going to be ugly as the event can have different shapes
even within the same EventFeedFormat, together with the minor changes
between formats.
  • Loading branch information
vmcj committed Feb 9, 2024
1 parent 1e55cb8 commit 6c21d59
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 32 deletions.
30 changes: 0 additions & 30 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,6 @@ parameters:
count: 1
path: webapp/src/FosRestBundle/FlattenExceptionHandler.php

-
message: "#^Method App\\\\Service\\\\ExternalContestSourceService\\:\\:addPendingEvent\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#"
count: 1
path: webapp/src/Service/ExternalContestSourceService.php

-
message: "#^Method App\\\\Service\\\\ExternalContestSourceService\\:\\:compareOrCreateValues\\(\\) has parameter \\$extraDiff with no value type specified in iterable type array\\.$#"
count: 1
Expand All @@ -84,36 +79,11 @@ parameters:
count: 1
path: webapp/src/Service/ExternalContestSourceService.php

-
message: "#^Method App\\\\Service\\\\ExternalContestSourceService\\:\\:getEventFeedFormat\\(\\) has parameter \\$event with no value type specified in iterable type array\\.$#"
count: 1
path: webapp/src/Service/ExternalContestSourceService.php

-
message: "#^Method App\\\\Service\\\\ExternalContestSourceService\\:\\:import\\(\\) has parameter \\$eventsToSkip with no value type specified in iterable type array\\.$#"
count: 1
path: webapp/src/Service/ExternalContestSourceService.php

-
message: "#^Method App\\\\Service\\\\ExternalContestSourceService\\:\\:importClarification\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#"
count: 1
path: webapp/src/Service/ExternalContestSourceService.php

-
message: "#^Method App\\\\Service\\\\ExternalContestSourceService\\:\\:importEvent\\(\\) has parameter \\$event with no value type specified in iterable type array\\.$#"
count: 1
path: webapp/src/Service/ExternalContestSourceService.php

-
message: "#^Method App\\\\Service\\\\ExternalContestSourceService\\:\\:importEvent\\(\\) has parameter \\$eventsToSKip with no value type specified in iterable type array\\.$#"
count: 1
path: webapp/src/Service/ExternalContestSourceService.php

-
message: "#^Method App\\\\Service\\\\ExternalContestSourceService\\:\\:importFromCcsApi\\(\\) has parameter \\$eventsToSkip with no value type specified in iterable type array\\.$#"
count: 1
path: webapp/src/Service/ExternalContestSourceService.php

-
message: "#^Method App\\\\Service\\\\ExternalContestSourceService\\:\\:importFromContestArchive\\(\\) has parameter \\$eventsToSkip with no value type specified in iterable type array\\.$#"
count: 1
Expand Down
41 changes: 39 additions & 2 deletions webapp/src/Service/ExternalContestSourceService.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,9 @@ public function getLastReadEventId(): ?string
->getSingleScalarResult();
}

/**
* @param string[] $eventsToSkip
*/
public function import(bool $fromStart, array $eventsToSkip, ?callable $progressReporter = null): bool
{
// We need the verdicts to validate judgement-types.
Expand Down Expand Up @@ -290,6 +293,9 @@ protected function setLastEvent(?string $eventId): void
->execute();
}

/**
* @param string[] $eventsToSkip
*/
protected function importFromCcsApi(array $eventsToSkip, ?callable $progressReporter = null): bool
{
while (true) {
Expand Down Expand Up @@ -568,11 +574,22 @@ protected function loadContest(): void

/**
* Import the given event.
*
* @param array{token?: string, id: string, type: string, time: string, op?: string, end_of_updates?: bool,
* data?: array{run_time?: float, time?: string, contest_time?: string, ordinal?: int,
* id: string, judgement_id?: string, judgement_type_id: string|null,
* max_run_time?: float|null, start_time: string, start_contest_time?: string,
* end_time?: string|null, end_contest_time?: string|null, submission_id: string,
* output_compile_as_string: null, language_id?: string, externalid?: null,
* team_id: string, problem_id?: string, entry_point?: string|null, old_result?: null,
* files?: array{href: string}}|mixed[]
* } $event
* @param string[] $eventsToSkip
* @throws DBALException
* @throws NonUniqueResultException
* @throws TransportExceptionInterface
*/
public function importEvent(array $event, array $eventsToSKip): void
public function importEvent(array $event, array $eventsToSkip): void
{
// Check whether we have received an exit signal.
if (function_exists('pcntl_signal_dispatch')) {
Expand Down Expand Up @@ -604,7 +621,7 @@ public function importEvent(array $event, array $eventsToSKip): void
$entityType = 'contests';
}

if ($eventId !== null && in_array($eventId, $eventsToSKip)) {
if ($eventId !== null && in_array($eventId, $eventsToSkip)) {
$this->logger->info("Skipping event with ID %s and type %s as requested",
[$eventId, $event['type']]);
return;
Expand Down Expand Up @@ -1776,6 +1793,15 @@ protected function processPendingEvents(string $type, string|int $id): void
}
}

/**
* @param array{run_time?: float, time?: string, contest_time?: string, ordinal?: int,
* id: string, judgement_id?: string, judgement_type_id: string|null,
* max_run_time?: float|null, start_time: string, start_contest_time?: string,
* end_time?: string|null, end_contest_time?: string|null, submission_id: string,
* output_compile_as_string: null, language_id?: string, externalid?: null,
* team_id: string, problem_id?: string, entry_point?: string|null, old_result?: null,
* files?: array{href: string}} $data
*/
protected function addPendingEvent(string $type, string|int $id, string $operation, string $entityType, ?string $eventId, array $data): void
{
// First, check if we already have pending events for this event.
Expand Down Expand Up @@ -1996,6 +2022,17 @@ protected function removeWarning(string $entityType, ?string $entityId, string $
}
}

/**
* @param array{token?: string, id: string, type: string, time: string, op?: string, end_of_updates?: bool,
* data?: array{run_time?: float, time?: string, contest_time?: string, ordinal?: int,
* id: string, judgement_id?: string, judgement_type_id: string|null,
* max_run_time?: float|null, start_time: string, start_contest_time?: string,
* end_time?: string|null, end_contest_time?: string|null, submission_id: string,
* output_compile_as_string: null, language_id?: string, externalid?: null,
* team_id: string, problem_id?: string, entry_point?: string|null, old_result?: null,
* files?: array{href: string}}|mixed[]
* } $event
*/
protected function getEventFeedFormat(array $event): EventFeedFormat
{
return match ($this->getApiVersion()) {
Expand Down

0 comments on commit 6c21d59

Please sign in to comment.