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

Side by Side Diff: go/autoroll/autoroll.go

Issue 1171823005: Add autoroll package, alerts for failed rolls, recent rolls on Status (Closed) Base URL: https://skia.googlesource.com/buildbot@master
Patch Set: Address comments Created 5 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
« no previous file with comments | « alertserver/go/alertserver/alertroutines.go ('k') | go/rietveld/rietveld.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 package autoroll
2
3 /*
4 Convenience functions for retrieving AutoRoll CLs.
5 */
6
7 import (
8 "time"
9
10 "go.skia.org/infra/go/rietveld"
11 "go.skia.org/infra/go/util"
12 )
13
14 const (
15 OWNER = "skia-deps-roller@chromium.org"
16 POLLER_ROLLS_LIMIT = 10
17 RECENT_ROLLS_LIMIT = 200
18 RIETVELD_URL = "https://codereview.chromium.org"
19 )
20
21 var r = rietveld.Rietveld{
22 Url: RIETVELD_URL,
23 }
24
25 // AutoRollIssue is a trimmed-down rietveld.Issue containing just the
26 // fields we care about for AutoRoll CLs.
27 type AutoRollIssue struct {
28 Closed bool
29 Committed bool
30 Issue int
31 Modified time.Time
32 }
33
34 func search(limit int, terms ...*rietveld.SearchTerm) ([]*AutoRollIssue, error) {
35 terms = append(terms, rietveld.SearchOwner(OWNER))
36 res, err := r.Search(limit, terms...)
37 if err != nil {
38 return nil, err
39 }
40 rv := make([]*AutoRollIssue, 0, len(res))
41 for _, i := range res {
42 rv = append(rv, &AutoRollIssue{
43 Closed: i.Closed,
44 Committed: i.Committed,
45 Issue: i.Issue,
46 Modified: i.Modified,
47 })
48 }
49 return rv, nil
50 }
51
52 // GetRecentRolls returns
53 func GetRecentRolls(modifiedAfter time.Time) ([]*AutoRollIssue, error) {
54 return search(RECENT_ROLLS_LIMIT, rietveld.SearchModifiedAfter(modifiedA fter))
55 }
56
57 func GetLastNRolls(n int) ([]*AutoRollIssue, error) {
58 issues, err := search(n)
59 if err != nil {
60 return nil, err
61 }
62 if len(issues) <= n {
63 return issues, nil
64 }
65 return issues[:n], nil
66 }
67
68 func AutoRollStatusPoller() (*util.PollingStatus, error) {
69 var v []*AutoRollIssue
70 return util.NewPollingStatus(&v, func(value interface{}) error {
71 res, err := GetLastNRolls(POLLER_ROLLS_LIMIT)
72 if err != nil {
73 return err
74 }
75 *value.(*[]*AutoRollIssue) = res
76 return nil
77 }, 1*time.Minute)
78 }
OLDNEW
« no previous file with comments | « alertserver/go/alertserver/alertroutines.go ('k') | go/rietveld/rietveld.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698