-
Notifications
You must be signed in to change notification settings - Fork 276
Shadowing: use DTO's #2331
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Shadowing: use DTO's #2331
Changes from all commits
8f40818
b35e850
948dae4
30a4448
69f46c3
20687ae
9ffb0ba
7f883d8
30032d4
2b9b930
34c2cfe
6eb5709
d10ca54
cbd96f6
23e7726
78c1edc
7570245
356e8ee
59719ff
7b13e51
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace App\DataTransferObject; | ||
|
||
use JMS\Serializer\Annotation as Serializer; | ||
|
||
class ApiInfoProvider | ||
{ | ||
public function __construct( | ||
public readonly string $name, | ||
public readonly string $version, | ||
#[Serializer\Exclude(if: '!object.buildDate')] | ||
public readonly ?string $buildDate = null, | ||
) {} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace App\DataTransferObject\Shadowing; | ||
|
||
class ClarificationEvent implements EventData | ||
{ | ||
public function __construct( | ||
public readonly string $id, | ||
public readonly string $text, | ||
public readonly string $time, | ||
public readonly ?string $fromTeamId, | ||
public readonly ?string $toTeamId, | ||
public readonly ?string $replyToId, | ||
public readonly ?string $problemId, | ||
) {} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace App\DataTransferObject\Shadowing; | ||
|
||
class ContestData | ||
{ | ||
public function __construct( | ||
public readonly string $id, | ||
public readonly string $name, | ||
public readonly string $duration, | ||
public readonly ?string $scoreboardFreezeDuration, | ||
public readonly int $penaltyTime, | ||
public readonly ?string $startTime, | ||
// TODO: check for end time and scoreboard thaw time | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably want to resolve before merging? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nope. @vmcj wanted this comment. It would be a new “feature” |
||
) {} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace App\DataTransferObject\Shadowing; | ||
|
||
class ContestEvent implements EventData | ||
{ | ||
public function __construct( | ||
public readonly string $id, | ||
public readonly string $name, | ||
public readonly string $duration, | ||
public readonly ?string $scoreboardType, | ||
public readonly int $penaltyTime, | ||
public readonly ?string $formalName, | ||
public readonly ?string $startTime, | ||
public readonly ?int $countdownPauseTime, | ||
public readonly ?string $scoreboardFreezeDuration, | ||
public readonly ?string $scoreboardThawTime, | ||
) {} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace App\DataTransferObject\Shadowing; | ||
|
||
/** | ||
* @template-covariant T of EventData | ||
*/ | ||
class Event | ||
{ | ||
/** | ||
* @param T[] $data | ||
*/ | ||
public function __construct( | ||
public readonly ?string $id, | ||
public readonly EventType $type, | ||
public readonly Operation $operation, | ||
public readonly ?string $objectId, | ||
public readonly array $data, | ||
) {} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace App\DataTransferObject\Shadowing; | ||
|
||
interface EventData | ||
{ | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace App\DataTransferObject\Shadowing; | ||
|
||
enum EventType: string | ||
{ | ||
case ACCOUNTS = 'accounts'; | ||
case AWARDS = 'awards'; | ||
case CLARIFICATIONS = 'clarifications'; | ||
case CONTESTS = 'contests'; | ||
case GROUPS = 'groups'; | ||
case JUDGEMENTS = 'judgements'; | ||
case JUDGEMENT_TYPES = 'judgement-types'; | ||
case LANGUAGES = 'languages'; | ||
case ORGANIZATIONS = 'organizations'; | ||
case PROBLEMS = 'problems'; | ||
case RUNS = 'runs'; | ||
case STATE = 'state'; | ||
case SUBMISSIONS = 'submissions'; | ||
case TEAMS = 'teams'; | ||
case TEAM_MEMBERS = 'team-members'; | ||
|
||
public static function fromString(string $value): EventType | ||
{ | ||
if ($value === 'contest') { | ||
return EventType::CONTESTS; | ||
} | ||
|
||
return EventType::from($value); | ||
} | ||
|
||
/** | ||
* @return class-string<EventData>|null | ||
*/ | ||
public function getEventClass(): ?string | ||
{ | ||
switch ($this) { | ||
case self::CLARIFICATIONS: | ||
return ClarificationEvent::class; | ||
case self::CONTESTS: | ||
return ContestEvent::class; | ||
case self::GROUPS: | ||
return GroupEvent::class; | ||
case self::JUDGEMENTS: | ||
return JudgementEvent::class; | ||
case self::JUDGEMENT_TYPES: | ||
return JudgementTypeEvent::class; | ||
case self::LANGUAGES: | ||
return LanguageEvent::class; | ||
case self::ORGANIZATIONS: | ||
return OrganizationEvent::class; | ||
case self::PROBLEMS: | ||
return ProblemEvent::class; | ||
case self::RUNS: | ||
return RunEvent::class; | ||
case self::STATE: | ||
return StateEvent::class; | ||
case self::SUBMISSIONS: | ||
return SubmissionEvent::class; | ||
case self::TEAMS: | ||
return TeamEvent::class; | ||
} | ||
return null; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace App\DataTransferObject\Shadowing; | ||
|
||
class GroupEvent implements EventData | ||
{ | ||
public function __construct( | ||
public readonly string $id, | ||
public readonly string $name, | ||
public readonly ?string $icpcId, | ||
public readonly ?bool $hidden, | ||
public readonly ?int $sortorder, | ||
public readonly ?string $color, | ||
) {} | ||
vmcj marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} |
Uh oh!
There was an error while loading. Please reload this page.