Skip to content

Commit

Permalink
feat(go/season-stat): adapt mesage proto
Browse files Browse the repository at this point in the history
  • Loading branch information
MikaelVallenet committed Apr 5, 2023
1 parent 51a4c2c commit 014f02a
Show file tree
Hide file tree
Showing 6 changed files with 353 additions and 518 deletions.
2 changes: 0 additions & 2 deletions api/pwapi.proto
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,7 @@ message AdminSeasonStats {
}
message Output {
message Stat {
int64 rank = 1;
pathwar.db.Team team = 2;
int64 score = 5;
int64 challenge_solved = 6;
}
repeated Stat stats = 1;
Expand Down
2 changes: 1 addition & 1 deletion docs/gen.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion go/gen.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 14 additions & 1 deletion go/pkg/pwapi/api_admin-season-stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package pwapi

import (
"context"

"pathwar.land/pathwar/v2/go/pkg/pwdb"

"pathwar.land/pathwar/v2/go/pkg/errcode"
Expand All @@ -15,10 +16,22 @@ func (svc *service) AdminSeasonStats(ctx context.Context, in *AdminSeasonStats_I
return nil, errcode.ErrMissingInput
}

_, err := pwdb.GetIDBySlugAndKind(svc.db, in.SeasonID, "season")
seasonID, err := pwdb.GetIDBySlugAndKind(svc.db, in.SeasonID, "season")
if err != nil {
return nil, err
}

// retrieve all teams for the given season and preload team_member and team_member.user
teams := []pwdb.Team{}
err = svc.db.
Preload("TeamMembers").
Preload("TeamMembers.User").
Where(&pwdb.Team{SeasonID: seasonID}).
Find(&teams).
Error
if err != nil {
return nil, errcode.TODO.Wrap(err)
}

return &AdminSeasonStats_Output{}, nil
}

0 comments on commit 014f02a

Please sign in to comment.