Ejemplo n.º 1
0
// Get returns the trybot results for the given issue from the datastore.
func (t *TrybotResultStorage) Get(issue string) (types.TryBotResults, error) {
	var results string
	err := t.vdb.DB.QueryRow("SELECT results FROM tries WHERE issue=?", issue).Scan(&results)
	if err == sql.ErrNoRows {
		return types.NewTryBotResults(), nil
	}
	if err != nil {
		return nil, fmt.Errorf("Failed to load try data with id %s: %s", issue, err)
	}

	try := types.TryBotResults{}
	if err := json.Unmarshal([]byte(results), &try); err != nil {
		return nil, fmt.Errorf("Failed to decode try data for issue %s. Error: %s", issue, err)
	}
	return try, nil
}
Ejemplo n.º 2
0
// See the ingester.ResultIngester interface.
func (t *TrybotResultIngester) Ingest(_ *ingester.TileTracker, opener ingester.Opener, fileInfo *ingester.ResultsFileLocation, counter metrics.Counter) error {
	r, err := opener()
	if err != nil {
		return fmt.Errorf("Unable to open reader: %s", err)
	}
	dmResults, err := goldingester.ParseDMResultsFromReader(r)
	if err != nil {
		return err
	}

	dmResults.ForEach(func(key, value string, params map[string]string) {
		if _, ok := t.resultsByIssue[dmResults.Issue]; !ok {
			t.resultsByIssue[dmResults.Issue] = types.NewTryBotResults()
		}
		t.resultsByIssue[dmResults.Issue].Update(key, params[types.PRIMARY_KEY_FIELD], value, params, fileInfo.LastUpdated)
	})

	counter.Inc(1)
	glog.Infof("Finished processing file %s.", fileInfo.Name)
	return nil
}