Fix bug in result listing

This commit is contained in:
Arturo Filastò 2018-09-10 16:56:32 +02:00
parent e0c0acffeb
commit e5c508a94c
4 changed files with 17 additions and 11 deletions

View File

@ -42,7 +42,7 @@ func init() {
}
for idx, result := range incompleteResults {
output.ResultItem(output.ResultItemData{
ID: result.Result.ID,
ID: result.ResultID,
Index: idx,
TotalCount: len(incompleteResults),
Name: result.TestGroupName,
@ -63,16 +63,16 @@ func init() {
netCount := make(map[uint]int)
output.SectionTitle("Results")
for idx, result := range doneResults {
totalCount, anmlyCount, err := database.GetMeasurementCounts(ctx.DB, result.Result.ID)
totalCount, anmlyCount, err := database.GetMeasurementCounts(ctx.DB, result.ResultID)
if err != nil {
log.WithError(err).Error("failed to list measurement counts")
}
testKeys, err := database.GetResultTestKeys(ctx.DB, result.Result.ID)
testKeys, err := database.GetResultTestKeys(ctx.DB, result.ResultID)
if err != nil {
log.WithError(err).Error("failed to get testKeys")
}
output.ResultItem(output.ResultItemData{
ID: result.Result.ID,
ID: result.ResultID,
Index: idx,
TotalCount: len(doneResults),
Name: result.TestGroupName,

View File

@ -80,6 +80,7 @@ func GetMeasurementCounts(sess sqlbuilder.Database, resultID int64) (uint64, uin
return totalCount, anmlyCount, err
}
log.Debugf("counts: %d, %d, %d", resultID, totalCount, anmlyCount)
return totalCount, anmlyCount, err
}
@ -90,8 +91,9 @@ func ListResults(sess sqlbuilder.Database) ([]ResultNetwork, []ResultNetwork, er
req := sess.Select(
"networks.id AS network_id",
db.Raw("results.*"),
"results.id AS result_id",
db.Raw("networks.*"),
db.Raw("results.*"),
).From("results").
Join("networks").On("results.network_id = networks.id").
OrderBy("results.start_time")

View File

@ -14,7 +14,9 @@ import (
// between the results and networks tables.
type ResultNetwork struct {
Result `db:",inline"`
ResultID int64 `db:"result_id"`
Network `db:",inline"`
NetworkID int64 `db:"network_id"`
}
// MeasurementURLNetwork is used for the JOIN between Measurement and URL

View File

@ -105,11 +105,13 @@ func logTable(w io.Writer, f log.Fields) error {
func (h *Handler) TypedLog(t string, e *log.Entry) error {
switch t {
case "progress":
var err error
s := fmt.Sprintf("%.2f%%: %-25s", e.Fields.Get("percentage").(float64)*100, e.Message)
fmt.Fprintf(h.Writer, s)
perc := e.Fields.Get("percentage").(float64) * 100
s := fmt.Sprintf(" %s\n %-25s",
bold.Sprintf("%.2f%%", perc),
bold.Sprint(e.Message))
fmt.Fprint(h.Writer, s)
fmt.Fprintln(h.Writer)
return err
return nil
case "table":
return logTable(h.Writer, e.Fields)
case "result_item":