Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(171)

Side by Side Diff: appengine/cmd/dm/mutate/add_finished_deps.go

Issue 1537883002: Initial distributor implementation (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-go@master
Patch Set: self review Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698