@@ -16,32 +16,26 @@ const (
16
16
)
17
17
18
18
type Status struct {
19
- Stat string
20
- ComparisonStat string
21
- Goal string
22
- State state
23
- Description string
19
+ State state
20
+ Description string
24
21
}
25
22
26
- func NewStatus (stat , comparisonStat , goal string ) (* Status , error ) {
27
- state , description , err := compareStats (stat , comparisonStat , goal )
23
+ func NewStatus (stat , comparisonStat , comparisonRef , goal string ) (* Status , error ) {
24
+ state , description , err := compareStats (stat , comparisonStat , comparisonRef , goal )
28
25
if err != nil {
29
26
return nil , err
30
27
}
31
28
return & Status {
32
- Stat : stat ,
33
- ComparisonStat : comparisonStat ,
34
- Goal : goal ,
35
- State : state ,
36
- Description : description ,
29
+ State : state ,
30
+ Description : description ,
37
31
}, nil
38
32
}
39
33
40
- func compareStats (stat , comparisonStat , goal string ) (state , string , error ) {
34
+ func compareStats (stat , comparisonStat , comparisonRef , goal string ) (state , string , error ) {
41
35
// IMPORTANT: the current stat needs to be the first thing in the description
42
36
// because that's how we will parse it back off
43
37
if comparisonStat == "" {
44
- return stateError , fmt .Sprintf ("%s - nothing to compare to (stat is either new or being processed simultaneously)" , stat ), nil
38
+ return stateError , fmt .Sprintf ("%s - nothing to compare on %s (stat is either new or being processed simultaneously)" , comparisonRef , stat ), nil
45
39
}
46
40
47
41
statNum , err := parse .ParseStatNumber (stat )
@@ -51,24 +45,24 @@ func compareStats(stat, comparisonStat, goal string) (state, string, error) {
51
45
52
46
prevStatNum , err := parse .ParseStatNumber (comparisonStat )
53
47
if err != nil {
54
- return stateError , "unable to parse comparison stat" , err
48
+ return stateError , fmt . Sprintf ( "unable to parse comparison stat from %s" , comparisonRef ) , err
55
49
}
56
50
57
51
if goal == "decrease" {
58
52
if statNum < prevStatNum {
59
- return stateSuccess , fmt .Sprintf ("%s - less than %s" , stat , comparisonStat ), nil
53
+ return stateSuccess , fmt .Sprintf ("%s - less than %s (%s) " , stat , comparisonStat , comparisonRef ), nil
60
54
} else if statNum == prevStatNum {
61
- return stateSuccess , fmt .Sprintf ("%s - no change" , stat ), nil
55
+ return stateSuccess , fmt .Sprintf ("%s - no change compared to %s " , stat , comparisonRef ), nil
62
56
} else {
63
- return stateFailure , fmt .Sprintf ("%s - more than %s" , stat , comparisonStat ), nil
57
+ return stateFailure , fmt .Sprintf ("%s - more than %s (%s) " , stat , comparisonStat , comparisonRef ), nil
64
58
}
65
59
} else if goal == "increase" {
66
60
if statNum > prevStatNum {
67
- return stateSuccess , fmt .Sprintf ("%s - more than %s" , stat , comparisonStat ), nil
61
+ return stateSuccess , fmt .Sprintf ("%s - more than %s (%s) " , stat , comparisonStat , comparisonRef ), nil
68
62
} else if statNum == prevStatNum {
69
- return stateSuccess , fmt .Sprintf ("%s - no change" , stat ), nil
63
+ return stateSuccess , fmt .Sprintf ("%s - no change compared to %s " , stat , comparisonRef ), nil
70
64
} else {
71
- return stateFailure , fmt .Sprintf ("%s - less than %s" , stat , comparisonStat ), nil
65
+ return stateFailure , fmt .Sprintf ("%s - less than %s (%s) " , stat , comparisonStat , comparisonRef ), nil
72
66
}
73
67
} else {
74
68
return stateError , "unknown goal" , errors .New ("unknown goal" )
0 commit comments