Skip to content

Commit

Permalink
feat: get /tournaments with /user-sessions
Browse files Browse the repository at this point in the history
  • Loading branch information
moul committed Sep 16, 2019
1 parent 6780daf commit eddc9b4
Show file tree
Hide file tree
Showing 6 changed files with 143 additions and 402 deletions.
10 changes: 4 additions & 6 deletions server/api.pub.tournaments.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"pathwar.land/entity"
)

func (s *svc) Tournaments(ctx context.Context, _ *Void) (*TournamentsOutput, error) {
func (s *svc) tournaments(ctx context.Context, _ *Void) ([]*UserSessionOutput_Tournament, error) {
var tournaments []*entity.Tournament
var memberships []*entity.TournamentMember

Expand All @@ -33,12 +33,10 @@ func (s *svc) Tournaments(ctx context.Context, _ *Void) (*TournamentsOutput, err
return nil, err
}

output := &TournamentsOutput{
Items: []*TournamentsOutput_Tournament{},
}
output := []*UserSessionOutput_Tournament{}

for _, tournament := range tournaments {
item := &TournamentsOutput_Tournament{
item := &UserSessionOutput_Tournament{
Tournament: tournament,
}

Expand All @@ -49,7 +47,7 @@ func (s *svc) Tournaments(ctx context.Context, _ *Void) (*TournamentsOutput, err
}
}

output.Items = append(output.Items, item)
output = append(output, item)
}

return output, nil
Expand Down
5 changes: 5 additions & 0 deletions server/api.pub.user-session.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ func (s *svc) UserSession(ctx context.Context, _ *Void) (*UserSessionOutput, err
// FIXME: output.Notifications = COUNT
output.Notifications = 42

output.Tournaments, err = s.tournaments(ctx, &Void{})
if err != nil {
return nil, err
}

return output, nil
}

Expand Down
Loading

0 comments on commit eddc9b4

Please sign in to comment.