-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Summary
Implement the backend API for squad CRUD operations and aggregate stats.
Details
REST Endpoints
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/v1/squads |
Create a new squad |
| GET | /api/v1/squads/:id |
Get squad details + members |
| PUT | /api/v1/squads/:id |
Update squad name |
| DELETE | /api/v1/squads/:id |
Delete a squad |
| POST | /api/v1/squads/:id/members |
Add a player to squad |
| DELETE | /api/v1/squads/:id/members/:playerId |
Remove player from squad |
| GET | /api/v1/squads/:id/stats |
Get aggregate squad stats |
Squad Stats Aggregation
GET /api/v1/squads/:id/stats returns:
{
"squad": { "id": "...", "name": "The Boys" },
"aggregate": {
"totalKills": 45000,
"totalWins": 890,
"avgKD": 1.35,
"totalTimePlayed": "120d 5h",
"totalMatches": 15000
},
"members": [
{
"gamertag": "player1",
"platform": "uno",
"stats": { /* individual stats */ },
"rank": 1 // rank within squad by K/D
}
],
"leaderboard": {
"mostKills": { "gamertag": "player2", "value": 18000 },
"bestKD": { "gamertag": "player1", "value": 1.8 },
"mostWins": { "gamertag": "player3", "value": 400 }
}
}Service Layer
internal/service/squad.go:CreateSquad(name string) (*Squad, error)AddMember(squadID, platform, gamertag string) errorRemoveMember(squadID, playerID string) errorGetSquadStats(squadID string) (*SquadStats, error)— fetches/caches each member's stats, computes aggregates
Validation
- Squad name: 1-50 characters
- Max 10 members per squad
- Prevent duplicate members in a squad
- Verify player exists (via CoD API) before adding
Acceptance Criteria
- All CRUD endpoints work and return appropriate status codes
- Squad stats aggregation computes correctly
- Leaderboard identifies top performers per stat
- Validation enforced (name length, max members, no duplicates)
- Player existence verified on member add
Reactions are currently unavailable