Exemplo n.º 1
0
func (e *ElasticWReport) Commit(r *models.Report, p []*models.Problem) error {
	r.Update()
	_, err := e.client.Index().Index(e.indexName).Type(TypoReportName).BodyJson(r).Id(e.rid).Do()

	bulk := e.client.Bulk()
	e.PutToBulk(bulk, p)
	_, err = bulk.Do()
	if err != nil {
		r.Error = err.Error()
		_, err = e.client.Index().Index(e.indexName).Type(TypoReportName).BodyJson(r).Id(e.rid).Do()
	}
	return err
}
Exemplo n.º 2
0
// The function creates a report as if we have already commited to it at least once and finished it
// (i.e., report.Finished and report.Updated are already set, report has Statistics, etc.)
// This is needed for mock-tests.
func NewReportWithNoProblems() *models.Report {
	report := new(models.Report)
	report.Name = "Report With No Problems"
	Created = time.Date(2015, 11, 01, 14, 55, 13, 0, time.Local)
	report.Created = &Created
	Updated = time.Date(2015, 11, 02, 14, 55, 13, 0, time.Local)
	report.Updated = &Updated
	Finished = time.Date(2015, 11, 02, 21, 00, 00, 0, time.Local)
	report.Finished = &Finished
	report.Error = ""
	report.Problems = EmptyProblemList
	report.Statistics = StatsForReportWithNoProblems
	return report
}
Exemplo n.º 3
0
// The function creates a report as if we have already commited to it at least once and finished it
// (i.e., report.Finished and report.Updated are already set, report has Statistics, etc.)
// This is needed for mock-tests.
func NewReportWithSomeProblems() *models.Report {
	report := new(models.Report)
	report.Name = "Report With Some Problems"
	Created = time.Date(2016, time.January, 13, 12, 10, 00, 00, time.UTC)
	report.Created = &Created
	Updated = time.Date(2016, time.January, 12, 12, 10, 00, 00, time.UTC)
	report.Updated = &Updated
	Finished = time.Date(2016, time.January, 12, 18, 00, 00, 00, time.UTC)
	report.Finished = &Finished
	report.Problems = Problems
	report.Error = ""
	report.Statistics = StatsForReportWithSomeProblems
	return report

}
Exemplo n.º 4
0
// The function creates a report as if we have already commited to it at least once and finished it
// (i.e., report.Finished and report.Updated are already set, report has Statistics, etc.)
// This is needed for mock-tests.
func NewReportWithError() *models.Report {
	report := new(models.Report)
	report.Name = "Report With Error"
	Created = time.Date(2015, time.October, 05, 10, 00, 45, 00, time.UTC)
	report.Created = &Created
	Updated = time.Date(2015, time.October, 06, 10, 00, 00, 00, time.UTC)
	report.Updated = &Updated
	report.Error = "An error occured while collecting problems -- report is partial!"
	report.Problems = Problems
	report.Statistics = StatsForReportWithError
	return report

}
Exemplo n.º 5
0
func (m *MemWriter) Finish(r *models.Report) error {
	r.Finish()
	return nil
}
Exemplo n.º 6
0
func (m *MemWriter) Commit(r *models.Report, p []*models.Problem) error {
	r.Update()
	r.Problems = append(r.Problems, p...)
	return nil
}
Exemplo n.º 7
0
func (e *ElasticWReport) Finish(r *models.Report) error {
	r.Finish()
	_, err := e.client.Index().Index(e.indexName).Type(TypoReportName).BodyJson(r).Id(e.rid).Do()
	return err
}