diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2017-11-16 09:58:02 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2017-11-16 09:58:02 +0100 |
| commit | 3ed60d0989a0781500d3eb02adfa0196c8eb71f2 (patch) | |
| tree | 4eedd5d0edacf5b41e34836a1c2613819f7a16c8 /dashboard | |
| parent | 89572feb6f1f2d82a49ae31013cac06709a74867 (diff) | |
dashboard/app: make findCrashForBug return crash key
Diffstat (limited to 'dashboard')
| -rw-r--r-- | dashboard/app/main.go | 2 | ||||
| -rw-r--r-- | dashboard/app/reporting.go | 23 |
2 files changed, 13 insertions, 12 deletions
diff --git a/dashboard/app/main.go b/dashboard/app/main.go index 0fc24f501..206fb46d2 100644 --- a/dashboard/app/main.go +++ b/dashboard/app/main.go @@ -223,7 +223,7 @@ func createUIBug(c context.Context, bug *Bug, state *ReportingState, managers [] func loadCrashesForBug(c context.Context, bug *Bug) ([]*uiCrash, error) { bugHash := bugKeyHash(bug.Namespace, bug.Title, bug.Seq) bugKey := datastore.NewKey(c, "Bug", bugHash, 0, nil) - crashes, err := queryCrashesForBug(c, bugKey, 100) + crashes, _, err := queryCrashesForBug(c, bugKey, 100) if err != nil { return nil, err } diff --git a/dashboard/app/reporting.go b/dashboard/app/reporting.go index 8643d2434..3e5c4a10b 100644 --- a/dashboard/app/reporting.go +++ b/dashboard/app/reporting.go @@ -104,7 +104,7 @@ func needReport(c context.Context, typ string, state *ReportingState, bug *Bug) return } - crash, err = findCrashForBug(c, bug) + crash, _, err = findCrashForBug(c, bug) if err != nil { status = fmt.Sprintf("%v: no crashes!", reporting.Name) reporting, bugReporting = nil, nil @@ -511,9 +511,10 @@ func bugReportingByName(bug *Bug, name string) *BugReporting { return nil } -func queryCrashesForBug(c context.Context, bugKey *datastore.Key, limit int) ([]*Crash, error) { +func queryCrashesForBug(c context.Context, bugKey *datastore.Key, limit int) ( + []*Crash, []*datastore.Key, error) { var crashes []*Crash - _, err := datastore.NewQuery("Crash"). + keys, err := datastore.NewQuery("Crash"). Ancestor(bugKey). Order("-ReproC"). Order("-ReproSyz"). @@ -522,21 +523,21 @@ func queryCrashesForBug(c context.Context, bugKey *datastore.Key, limit int) ([] Limit(limit). GetAll(c, &crashes) if err != nil { - return nil, fmt.Errorf("failed to fetch crashes: %v", err) + return nil, nil, fmt.Errorf("failed to fetch crashes: %v", err) } - return crashes, nil + return crashes, keys, nil } -func findCrashForBug(c context.Context, bug *Bug) (*Crash, error) { +func findCrashForBug(c context.Context, bug *Bug) (*Crash, *datastore.Key, error) { bugKey := datastore.NewKey(c, "Bug", bugKeyHash(bug.Namespace, bug.Title, bug.Seq), 0, nil) - crashes, err := queryCrashesForBug(c, bugKey, 1) + crashes, keys, err := queryCrashesForBug(c, bugKey, 1) if err != nil { - return nil, fmt.Errorf("failed to fetch crashes: %v", err) + return nil, nil, err } if len(crashes) < 1 { - return nil, fmt.Errorf("no crashes") + return nil, nil, fmt.Errorf("no crashes") } - crash := crashes[0] + crash, key := crashes[0], keys[0] if bug.ReproLevel == ReproLevelC { if crash.ReproC == 0 { log.Errorf(c, "bug '%v': has C repro, but crash without C repro", bug.Title) @@ -550,7 +551,7 @@ func findCrashForBug(c context.Context, bug *Bug) (*Crash, error) { log.Errorf(c, "bug '%v': has report, but crash without report", bug.Title) } } - return crash, nil + return crash, key, nil } func loadReportingState(c context.Context) (*ReportingState, error) { |
