@@ 43,12 43,12 @@ type DirectiveRoot struct {
type ComplexityRoot struct {
Mutation struct {
- CancelMatch func(childComplexity int, id int) int
+ CancelMatch func(childComplexity int) int
CancelQueue func(childComplexity int, teamspeakID string) int
CreateMatch func(childComplexity int) int
CreateUser func(childComplexity int, input model.NewUser) int
DeleteUser func(childComplexity int, id int) int
- FinishMatch func(childComplexity int, id int, winner string) int
+ FinishMatch func(childComplexity int, winner string) int
StartQueue func(childComplexity int, teamspeakID string) int
UpdateUser func(childComplexity int, id int, input model.UserInput) int
}
@@ 76,8 76,8 @@ type MutationResolver interface {
StartQueue(ctx context.Context, teamspeakID string) (int, error)
CancelQueue(ctx context.Context, teamspeakID string) (int, error)
CreateMatch(ctx context.Context) (int, error)
- CancelMatch(ctx context.Context, id int) (string, error)
- FinishMatch(ctx context.Context, id int, winner string) (string, error)
+ CancelMatch(ctx context.Context) (string, error)
+ FinishMatch(ctx context.Context, winner string) (string, error)
}
type QueryResolver interface {
UserBySteam(ctx context.Context, steamID string) (*model.User, error)
@@ 104,12 104,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
break
}
- args, err := ec.field_Mutation_cancelMatch_args(context.TODO(), rawArgs)
- if err != nil {
- return 0, false
- }
-
- return e.complexity.Mutation.CancelMatch(childComplexity, args["id"].(int)), true
+ return e.complexity.Mutation.CancelMatch(childComplexity), true
case "Mutation.cancelQueue":
if e.complexity.Mutation.CancelQueue == nil {
@@ 164,7 159,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
return 0, false
}
- return e.complexity.Mutation.FinishMatch(childComplexity, args["id"].(int), args["winner"].(string)), true
+ return e.complexity.Mutation.FinishMatch(childComplexity, args["winner"].(string)), true
case "Mutation.startQueue":
if e.complexity.Mutation.StartQueue == nil {
@@ 363,8 358,8 @@ type Mutation {
startQueue(teamspeakID: String!): Int!
cancelQueue(teamspeakID: String!): Int!
createMatch: Int!
- cancelMatch(id: Int!): String!
- finishMatch(id: Int!, winner: String!): String!
+ cancelMatch: String!
+ finishMatch(winner: String!): String!
}
`, BuiltIn: false},
}
@@ 374,21 369,6 @@ var parsedSchema = gqlparser.MustLoadSchema(sources...)
// region ***************************** args.gotpl *****************************
-func (ec *executionContext) field_Mutation_cancelMatch_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
- var err error
- args := map[string]interface{}{}
- var arg0 int
- if tmp, ok := rawArgs["id"]; ok {
- ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id"))
- arg0, err = ec.unmarshalNInt2int(ctx, tmp)
- if err != nil {
- return nil, err
- }
- }
- args["id"] = arg0
- return args, nil
-}
-
func (ec *executionContext) field_Mutation_cancelQueue_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
var err error
args := map[string]interface{}{}
@@ 437,24 417,15 @@ func (ec *executionContext) field_Mutation_deleteUser_args(ctx context.Context,
func (ec *executionContext) field_Mutation_finishMatch_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
var err error
args := map[string]interface{}{}
- var arg0 int
- if tmp, ok := rawArgs["id"]; ok {
- ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id"))
- arg0, err = ec.unmarshalNInt2int(ctx, tmp)
- if err != nil {
- return nil, err
- }
- }
- args["id"] = arg0
- var arg1 string
+ var arg0 string
if tmp, ok := rawArgs["winner"]; ok {
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("winner"))
- arg1, err = ec.unmarshalNString2string(ctx, tmp)
+ arg0, err = ec.unmarshalNString2string(ctx, tmp)
if err != nil {
return nil, err
}
}
- args["winner"] = arg1
+ args["winner"] = arg0
return args, nil
}
@@ 838,16 809,9 @@ func (ec *executionContext) _Mutation_cancelMatch(ctx context.Context, field gra
}
ctx = graphql.WithFieldContext(ctx, fc)
- rawArgs := field.ArgumentMap(ec.Variables)
- args, err := ec.field_Mutation_cancelMatch_args(ctx, rawArgs)
- if err != nil {
- ec.Error(ctx, err)
- return graphql.Null
- }
- fc.Args = args
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
- return ec.resolvers.Mutation().CancelMatch(rctx, args["id"].(int))
+ return ec.resolvers.Mutation().CancelMatch(rctx)
})
if err != nil {
ec.Error(ctx, err)
@@ 889,7 853,7 @@ func (ec *executionContext) _Mutation_finishMatch(ctx context.Context, field gra
fc.Args = args
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
- return ec.resolvers.Mutation().FinishMatch(rctx, args["id"].(int), args["winner"].(string))
+ return ec.resolvers.Mutation().FinishMatch(rctx, args["winner"].(string))
})
if err != nil {
ec.Error(ctx, err)
@@ 311,12 311,12 @@ func (r *mutationResolver) CreateMatch(ctx context.Context) (int, error) {
return matchID, nil
}
-func (r *mutationResolver) CancelMatch(ctx context.Context, id int) (string, error) {
+func (r *mutationResolver) CancelMatch(ctx context.Context) (string, error) {
query := `
UPDATE "Match"
SET status = 'cancelled'
- WHERE id = $1 AND status = 'ongoing'`
- result, err := database.DB.Exec(query, id)
+ WHERE status = 'ongoing'`
+ result, err := database.DB.Exec(query)
if err != nil {
return "CancelFail", err
}
@@ 327,24 327,24 @@ func (r *mutationResolver) CancelMatch(ctx context.Context, id int) (string, err
}
if count != 1 {
- return "CancelFail", errors.New("match is not ongoing")
+ return "CancelFail", errors.New("no match ongoing")
}
return "CancelSuccess", nil
}
-func (r *mutationResolver) FinishMatch(ctx context.Context, id int, winner string) (string, error) {
+func (r *mutationResolver) FinishMatch(ctx context.Context, winner string) (string, error) {
var team1, team2 logic.Team
query := `
SELECT t1, t2, elo1, elo2
FROM "Match"
- WHERE id = $1 and status = 'ongoing'`
- err := database.DB.QueryRow(query, id).
+ WHERE status = 'ongoing'`
+ err := database.DB.QueryRow(query).
Scan(&team1.ID, &team2.ID, &team1.Elo, &team2.Elo)
if err != nil {
if errors.Is(err, sql.ErrNoRows) {
- return "FinishFail", errors.New("match is not ongoing")
+ return "FinishFail", errors.New("no match ongoing")
}
return "FinishFail", err
}
@@ 376,8 376,8 @@ func (r *mutationResolver) FinishMatch(ctx context.Context, id int, winner strin
query = `
UPDATE "Match"
SET status = 'finished'
- WHERE id = $1`
- _, err = tx.Exec(query, id)
+ WHERE status = 'ongoing'`
+ _, err = tx.Exec(query)
if err != nil {
return "FinishFail", err
}