-
Notifications
You must be signed in to change notification settings - Fork 63
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
Feature/#747 save additional metadata in game results #782
Feature/#747 save additional metadata in game results #782
Conversation
First pass, saving work
Codecov Report
|
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.
This is a great start! I think some things can actually be simplified a little bit.
After reading this PR, I think the feature boils down to 3 chunks of work that we should tackle in the following order:
- Save the metadata on the GameResultReport object instead of ignoring them
- Include the metadata in the EndedGameInfo object
- Add conflict resolution for metadata
So I'll probably try to focus my reviews in that order as well.
We'll definitely need some integration tests, but it may be easier to write those with the changes from my broadcast PR.
server/games/game.py
Outdated
@@ -466,11 +474,21 @@ async def resolve_game_results(self) -> EndedGameInfo: | |||
team_outcomes = [GameOutcome.UNKNOWN for _ in basic_info.teams] | |||
|
|||
if self.validity is ValidityState.VALID: | |||
team_player_partial_outcomes = [] |
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.
Maybe this is beyond the scope of this PR, but I think we actually want these rabbitmq messages to go out even for games that are not marked as VALID
. In the case of GW I would expect many games to be invalid either due to mods or unbalanced teams.
If this complicates things too much for you don't worry about it for now, we'll make an issue and do it separately.
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.
Ah ok, I'll look into it and see if I can manage it.
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.
Have taken a stab at it, let me know what you think?
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.
For some reason I thought the messages wouldn't be sent to rabbitmq if the game wasn't valid, but looking over the code again I don't think that's the case. GameService.publish_game_results
always publishes to rmq, and only sends to the rating service if the game wasn't valid, which is the behavior we want.
So I think you can just remove that if self.validity is VALID
check and everything will work as expected. Definitely want a test or two to confirm tho.
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.
Hmm, ok, will take a look at 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.
Yes! This looks really good now; much simpler than it was at first.
Lastly I'd like to see some integration tests, which means I guess I had better get a move on with my rabbitmq PR. You could also copy the AioQueueProtocol
helper class and then rebase again once it's merged. Or maybe this will be merged first and then I can rebase my PR, doesn't really matter.
server/games/game.py
Outdated
team_outcomes = [GameOutcome.UNKNOWN for _ in basic_info.teams] | ||
|
||
if self.validity is ValidityState.VALID: | ||
if self.validity == ValidityState.VALID: |
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.
So looks like you are gonna keep this in for now?
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.
Yeah I thought this might be better as a separate PR as it looked like I might have to alter the logic of game_results.resolve_game
as well and we might want to be able to roll that back easily without undoing the changes in this PR?
Alright, I'm merging this. Here's something quirky I noticed, but it's only because we're using python3.7. When the end game result is logged, it prints out the object before serialization (no problem this is actually nice for printing enums) and in python3.7 the return value of
However, in python3.8 the return value is just a normal dict so lets just leave it. (I'll have to give upgrading another shot at some point) |
Some third parties, and in future Galactic War, will send additional information with game result messages like
This PR captures those additional tags, tries to resolve them across multiple messages, and finally adds them to the
TeamRatingSummary
object(s) that we broadcast at the end of a game.I'm not 100% happy with the naming of things, it feels like there are a lot of objects or enumerators named like
*Result
,*Score
and*Info
and I'm not sure if there are or should be clear distinctions about when to use each noun. I've also erred on the side of caution when resolving the metadata tags: if there's any discrepancy in the tags sent for an army then we'll only return the tags that exist in all messages. We may want to be more lenient than that.Closes #747.