🔧 fix: conditionally display duration and CS based on bot environment#1985
🔧 fix: conditionally display duration and CS based on bot environment#1985
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds conditional logic to display different estimated duration and CS (Contract Score) values based on whether the bot is running in development mode. The changes ensure that the dev bot shows maximum estimates (EstimatedDurationMax, CxpMax) while the production bot shows standard estimates (EstimatedDuration, Cxp).
Key Changes
- Added
config.IsDevBot()conditional check to differentiate between dev and production environments - Dev bot now displays
EstimatedDurationMaxandCxpMaxvalues for debugging/testing purposes - Production bot continues to display standard
EstimatedDurationandCxpvalues
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if config.IsDevBot() { | ||
| fmt.Fprintf(&builder, "**Duration:** %s **Est. Duration:** %s\n", bottools.FmtDuration(time.Duration(evaluation.GetCompletionTime()*float64(time.Second))), bottools.FmtDuration(c.EstimatedDurationMax)) | ||
| fmt.Fprintf(&builder, "**CS:** %d **Est CS:** %.0f (SR estimation)\n", uint32(evaluationCxp), c.CxpMax) | ||
| } else { | ||
| fmt.Fprintf(&builder, "**Duration:** %s **Est. Duration:** %s\n", bottools.FmtDuration(time.Duration(evaluation.GetCompletionTime()*float64(time.Second))), bottools.FmtDuration(c.EstimatedDuration)) | ||
| fmt.Fprintf(&builder, "**CS:** %d **Est CS:** %.0f (SR estimation)\n", uint32(evaluationCxp), c.Cxp) | ||
| } |
There was a problem hiding this comment.
These two branches duplicate the formatting logic and only differ in the variable used for estimated values. Consider extracting the condition to select the appropriate variables first, then use a single fmt.Fprintf call. This would improve maintainability by eliminating the duplication.
For example:
estimatedDuration := c.EstimatedDuration
estimatedCxp := c.Cxp
if config.IsDevBot() {
estimatedDuration = c.EstimatedDurationMax
estimatedCxp = c.CxpMax
}
fmt.Fprintf(&builder, "**Duration:** %s **Est. Duration:** %s\n", bottools.FmtDuration(time.Duration(evaluation.GetCompletionTime()*float64(time.Second))), bottools.FmtDuration(estimatedDuration))
fmt.Fprintf(&builder, "**CS:** %d **Est CS:** %.0f (SR estimation)\n", uint32(evaluationCxp), estimatedCxp)
| if config.IsDevBot() { | |
| fmt.Fprintf(&builder, "**Duration:** %s **Est. Duration:** %s\n", bottools.FmtDuration(time.Duration(evaluation.GetCompletionTime()*float64(time.Second))), bottools.FmtDuration(c.EstimatedDurationMax)) | |
| fmt.Fprintf(&builder, "**CS:** %d **Est CS:** %.0f (SR estimation)\n", uint32(evaluationCxp), c.CxpMax) | |
| } else { | |
| fmt.Fprintf(&builder, "**Duration:** %s **Est. Duration:** %s\n", bottools.FmtDuration(time.Duration(evaluation.GetCompletionTime()*float64(time.Second))), bottools.FmtDuration(c.EstimatedDuration)) | |
| fmt.Fprintf(&builder, "**CS:** %d **Est CS:** %.0f (SR estimation)\n", uint32(evaluationCxp), c.Cxp) | |
| } | |
| estimatedDuration := c.EstimatedDuration | |
| estimatedCxp := c.Cxp | |
| if config.IsDevBot() { | |
| estimatedDuration = c.EstimatedDurationMax | |
| estimatedCxp = c.CxpMax | |
| } | |
| fmt.Fprintf(&builder, "**Duration:** %s **Est. Duration:** %s\n", bottools.FmtDuration(time.Duration(evaluation.GetCompletionTime()*float64(time.Second))), bottools.FmtDuration(estimatedDuration)) | |
| fmt.Fprintf(&builder, "**CS:** %d **Est CS:** %.0f (SR estimation)\n", uint32(evaluationCxp), estimatedCxp) |
|
@copilot open a new pull request to apply changes based on the comments in this thread |
No description provided.