| OLD | NEW |
| 1 // Copyright 2015 The LUCI Authors. All rights reserved. | 1 // Copyright 2015 The LUCI Authors. All rights reserved. |
| 2 // Use of this source code is governed under the Apache License, Version 2.0 | 2 // Use of this source code is governed under the Apache License, Version 2.0 |
| 3 // that can be found in the LICENSE file. | 3 // that can be found in the LICENSE file. |
| 4 | 4 |
| 5 package mutate | 5 package mutate |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "github.com/luci/gae/service/datastore" | 8 "github.com/luci/gae/service/datastore" |
| 9 "github.com/luci/luci-go/appengine/cmd/dm/model" | 9 "github.com/luci/luci-go/appengine/cmd/dm/model" |
| 10 "github.com/luci/luci-go/appengine/tumble" | 10 "github.com/luci/luci-go/appengine/tumble" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 // here must be a subset of the quests mentioned in FinishedAttempts. | 21 // here must be a subset of the quests mentioned in FinishedAttempts. |
| 22 MergeQuests []*model.Quest | 22 MergeQuests []*model.Quest |
| 23 | 23 |
| 24 // FinishedAttempts are a list of attempts that we already know are in t
he | 24 // FinishedAttempts are a list of attempts that we already know are in t
he |
| 25 // Finished state. | 25 // Finished state. |
| 26 FinishedAttempts *dm.AttemptList | 26 FinishedAttempts *dm.AttemptList |
| 27 } | 27 } |
| 28 | 28 |
| 29 // Root implements tumble.Mutation | 29 // Root implements tumble.Mutation |
| 30 func (f *AddFinishedDeps) Root(c context.Context) *datastore.Key { | 30 func (f *AddFinishedDeps) Root(c context.Context) *datastore.Key { |
| 31 » return datastore.Get(c).KeyForObj(&model.Attempt{ID: *f.Auth.Id.AttemptI
D()}) | 31 » return model.AttemptKeyFromID(c, f.Auth.Id.AttemptID()) |
| 32 } | 32 } |
| 33 | 33 |
| 34 // RollForward implements tumble.Mutation | 34 // RollForward implements tumble.Mutation |
| 35 func (f *AddFinishedDeps) RollForward(c context.Context) (muts []tumble.Mutation
, err error) { | 35 func (f *AddFinishedDeps) RollForward(c context.Context) (muts []tumble.Mutation
, err error) { |
| 36 atmpt, _, err := model.AuthenticateExecution(c, f.Auth) | 36 atmpt, _, err := model.AuthenticateExecution(c, f.Auth) |
| 37 if err != nil { | 37 if err != nil { |
| 38 return | 38 return |
| 39 } | 39 } |
| 40 | 40 |
| 41 fwdDeps, err := filterExisting(c, model.FwdDepsFromList(c, f.Auth.Id.Att
emptID(), f.FinishedAttempts)) | 41 fwdDeps, err := filterExisting(c, model.FwdDepsFromList(c, f.Auth.Id.Att
emptID(), f.FinishedAttempts)) |
| 42 if err != nil || len(fwdDeps) == 0 { | 42 if err != nil || len(fwdDeps) == 0 { |
| 43 return | 43 return |
| 44 } | 44 } |
| 45 | 45 |
| 46 muts = make([]tumble.Mutation, 0, len(fwdDeps)+len(f.MergeQuests)) | 46 muts = make([]tumble.Mutation, 0, len(fwdDeps)+len(f.MergeQuests)) |
| 47 for _, d := range fwdDeps { | 47 for _, d := range fwdDeps { |
| 48 d.ForExecution = atmpt.CurExecution | 48 d.ForExecution = atmpt.CurExecution |
| 49 muts = append(muts, &AddBackDep{Dep: d.Edge()}) | 49 muts = append(muts, &AddBackDep{Dep: d.Edge()}) |
| 50 } | 50 } |
| 51 for _, q := range f.MergeQuests { | 51 for _, q := range f.MergeQuests { |
| 52 » » muts = append(muts, &MergeQuest{q}) | 52 » » muts = append(muts, &MergeQuest{Quest: q}) |
| 53 } | 53 } |
| 54 | 54 |
| 55 return muts, datastore.Get(c).PutMulti(fwdDeps) | 55 return muts, datastore.Get(c).PutMulti(fwdDeps) |
| 56 } | 56 } |
| 57 | 57 |
| 58 func init() { | 58 func init() { |
| 59 tumble.Register((*AddFinishedDeps)(nil)) | 59 tumble.Register((*AddFinishedDeps)(nil)) |
| 60 } | 60 } |
| OLD | NEW |