-
Notifications
You must be signed in to change notification settings - Fork 10
/
dedup_runs.go
67 lines (54 loc) · 1.22 KB
/
dedup_runs.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package main
import (
"context"
"flag"
"fmt"
"cloud.google.com/go/datastore"
"github.com/web-platform-tests/wpt.fyi/shared"
"google.golang.org/api/iterator"
)
var (
projectID = flag.String("project", "wptdashboard-staging", "Google Cloud project")
)
func print(run *shared.TestRun) {
fmt.Printf("%d %s-%s %s-%s %s\n", run.ID, run.BrowserName, run.BrowserVersion, run.OSName, run.OSVersion, run.ResultsURL)
}
func main() {
flag.Parse()
ctx := context.Background()
dsClient, err := datastore.NewClient(ctx, *projectID)
if err != nil {
panic(err)
}
query := datastore.NewQuery("TestRun").Order("-RawResultsURL")
var lastRun shared.TestRun
var printedFirst bool
for t := dsClient.Run(ctx, query); ; {
key, err := t.Next(nil)
if err == iterator.Done {
break
}
if err != nil {
panic(err)
}
var run shared.TestRun
dsClient.Get(ctx, key, &run)
run.ID = key.ID
if run.RawResultsURL == "" {
break
}
if run.RawResultsURL == lastRun.RawResultsURL {
if !printedFirst {
fmt.Printf("Found duplicate(s) of: ")
printedFirst = true
print(&lastRun)
}
fmt.Printf("Deleting: ")
print(&run)
dsClient.Delete(ctx, key)
} else {
printedFirst = false
}
lastRun = run
}
}