-
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good enough to merge as is, there are some discussion points left for future PRs.
|
||
class Award implements EventData | ||
{ | ||
// Not used currently, so no fields |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why does the class exist then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise we need special checks for unknown events. This makes the code a bit cleaner
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you prefer to add the special cases to the ExternalContestSourceService?
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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
Nope. @vmcj wanted this comment. It would be a new “feature”
|
||
class TeamMember implements EventData | ||
{ | ||
// Not used currently, so no fields |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above, is it necessary?
bool $fromStart, | ||
array $eventsToSkip, | ||
?callable $progressReporter = null | ||
): bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see this is the same change as in #2343 so I suppose that PR indeed contains duplicate commits.
Also, like my comment there: can we please not do reformatting of code that is not otherwise touched by your changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My bad. I am very used to (at work) reformat a file with a code style before saving to make it in sync.
I will try to undo all these reformat changes (even though they don't adhere to the code style).
$freezeHour = floor($freezeStartSeconds / 3600); | ||
$freezeMinutes = floor(($freezeStartSeconds % 3600) / 60); | ||
$freezeSeconds = floor(($freezeStartSeconds % 60) / 60); | ||
$freezeMilliseconds = $freezeStartSeconds - floor($freezeStartSeconds); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I disagree with this kind of removal of alignment spaces. It makes the code less readable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My bad, this is what the code style currently says. I will undo these changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know exactly what the current code style says, but I strongly think that automatic reformatting of alignment like this should be removed from it. Code formatting is a means to an end (better readability of code) and not a goal in itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe the problem is it wants some alignment and you can’t say “do whatever there was” but I hope I’m wrong since that would save me time
|
||
$eventType = EventType::fromString($data['type']); | ||
if ($this->getEventFeedFormat($data, $context) === EventFeedFormat::Format_2022_07) { | ||
$operation = !isset($data['data']) ? Operation::DELETE : Operation::CREATE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$operation = !isset($data['data']) ? Operation::DELETE : Operation::CREATE; | |
$operation = isset($data['data']) ? Operation::CREATE : Operation::DELETE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the reason for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's more readable?
@vmcj found an issue with legacy delete events. I will fix that but before doing that add tests for some events so we know they are parsed correctly. |
{ | ||
$hash = ExternalSourceWarning::calculateHash($type, $entityType, $entityId); | ||
$warning = $this->em | ||
$hash = ExternalSourceWarning::calculateHash($type, $eventType->value, $entityId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if you touch this in your PR or if it was already broken but calculateHash expects a string for $entityId
but that can be null
29397c1
to
044b085
Compare
Co-authored-by: MCJ Vasseur <[email protected]>
Co-authored-by: MCJ Vasseur <[email protected]>
Also add comment to event classes that are unused.
Also fix some logic errors.
044b085
to
7b13e51
Compare
This should have (almost) no functional changes, but it uses DTO's for reading from the event feed, making it that we can get rid of a lot of array shapes and that we get added type safety.
I did add the
provider
object to the API root endpoint, so we can reuse it here and added some small improvements, see the separate commits.