Track contributions for team achievements. - #137
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds contribution tracking for team achievements, allowing the system to record and display which team members contributed to achievement progress and when.
Key Changes:
- Updated team achievement method signatures to use
TeamAchievementtypes instead of genericAchievementtypes - Added new protobuf message types for team achievements with contributor tracking
- Defined
TeamAchievementContributormessage to track individual user contributions
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| teams.go | Updated interface method signatures to return team-specific achievement types |
| hiro.proto | Added new message types for team achievements with contributor tracking and updated RPC output types |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| int64 start_time_sec = 22; | ||
| // The UNIX timestamp when this achievement will allow updates. This may be before its next reset. A zero means it does not end. | ||
| int64 end_time_sec = 23; |
There was a problem hiding this comment.
Line 3151 describes end_time_sec but states 'when this achievement will allow updates', which appears to be copied from the start_time_sec comment above. The comment should clarify that end_time_sec represents when the achievement stops allowing updates or when it ends.
| message TeamAchievementContributor { | ||
| // User identifier. | ||
| string user_id = 1; | ||
| // Username. | ||
| string username = 2; | ||
| // Avatar URL. | ||
| string avatar_url = 3; | ||
| // Display name. | ||
| string display_name = 4; | ||
| // The UNIX time (for gRPC clients) or ISO string (for REST clients) when the user first contributed. | ||
| int64 create_time_sec = 5; | ||
| // The UNIX time (for gRPC clients) or ISO string (for REST clients) when the user most recently updated their contribution. | ||
| int64 update_time_sec = 6; | ||
| // Count contributed by this user. | ||
| int64 count = 7; | ||
| } |
There was a problem hiding this comment.
It would be useful to have a metadata field here similar to the TeamEventLeaderboardsContributors. What do you think?
# Conflicts: # hiro.pb.go
29d9f7b to
add1e9d
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 3 changed files in this pull request and generated no new comments.
Suppressed comments (2)
teams.go:202
- ResetAchievements still returns user-level *Achievement types while the other team achievement methods in this interface now return *TeamAchievement. This makes the team achievements API inconsistent and will force callers to handle two different result shapes for the same domain object (and may break any implementation expecting TeamAchievement everywhere).
UpdateAchievements(ctx context.Context, logger runtime.Logger, nk runtime.NakamaModule, userID, teamID string, achievementUpdates map[string]int64) (achievements map[string]*TeamAchievement, repeatAchievements map[string]*TeamAchievement, err error)
// ResetAchievements resets one or more achievements by their IDs by deleting their progress from the storage entry.
ResetAchievements(ctx context.Context, logger runtime.Logger, nk runtime.NakamaModule, userID, teamID string, achievementIDs []string) (achievements map[string]*Achievement, repeatAchievements map[string]*Achievement, err error)
hiro.proto:147
- The TEAMS_ACHIEVEMENTS RPCs now declare TeamAchievementsUpdateAck/TeamAchievementList as outputs, but the checked-in OpenAPI spec still references AchievementsUpdateAck and AchievementList for these endpoints (hiro-openapi.yml:1150-1215). If OpenAPI/client artifacts are expected to stay in sync with hiro.proto, they need to be regenerated/updated to match these new response message types.
// Claim one or more team achievements which have completed their progress.
RPC_ID_TEAMS_ACHIEVEMENTS_CLAIM = 105 [(input) = "TeamAchievementsClaimRequest", (output) = "TeamAchievementsUpdateAck"];
// Get all team achievements with progress accumulated by the team.
RPC_ID_TEAMS_ACHIEVEMENTS_GET = 106 [(input) = "TeamAchievementsGetRequest", (output) = "TeamAchievementList"];
// Update one or more team achievements with the same progress amount.
RPC_ID_TEAMS_ACHIEVEMENTS_UPDATE = 107 [(input) = "TeamAchievementsUpdateRequest", (output) = "TeamAchievementsUpdateAck"];
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 4 changed files in this pull request and generated no new comments.
Suppressed comments (4)
hiro-openapi.yml:6506
- TeamAchievementList is defined with an empty properties block, but the proto message includes achievements and repeat_achievements maps of TeamAchievement. Add these so REST/OpenAPI clients can rely on the documented response shape.
TeamAchievementList:
type: object
properties:
teams.go:203
- TeamsSystem achievement methods now return TeamAchievement, but ResetAchievements still returns Achievement. This makes the interface inconsistent and likely forces callers/implementers to handle two different achievement shapes (and loses contributor data on reset results). Consider updating ResetAchievements to return TeamAchievement as well for consistency with Claim/Get/Update.
UpdateAchievements(ctx context.Context, logger runtime.Logger, nk runtime.NakamaModule, userID, teamID string, achievementUpdates map[string]int64) (achievements map[string]*TeamAchievement, repeatAchievements map[string]*TeamAchievement, err error)
// ResetAchievements resets one or more achievements by their IDs by deleting their progress from the storage entry.
ResetAchievements(ctx context.Context, logger runtime.Logger, nk runtime.NakamaModule, userID, teamID string, achievementIDs []string) (achievements map[string]*Achievement, repeatAchievements map[string]*Achievement, err error)
hiro-openapi.yml:6481
- TeamAchievement in OpenAPI is missing the sub_achievements map that exists in hiro.proto (map<string, TeamSubAchievement> sub_achievements). This makes the REST schema incomplete for clients consuming nested/sub-achievement progress and contributor data.
available_total_reward:
$ref: '#/components/schemas/AvailableRewards'
total_reward:
$ref: '#/components/schemas/Reward'
auto_claim:
hiro-openapi.yml:6504
- TeamAchievementsUpdateAck is defined with an empty properties block, but the proto message includes achievements and repeat_achievements maps of TeamAchievement. Without these properties the REST/OpenAPI response contract is effectively undocumented/incorrect.
This issue also appears on line 6504 of the same file.
TeamAchievementsUpdateAck:
type: object
properties:
TeamAchievementList:
No description provided.