enrichOutcomeWithObjectiveValue computes the objective value for an outcome by fetching its associated issue/PR labels and applying the label-to-value mapping.
(report *OutcomeReport, repo string, mapping *github.ObjectiveMapping)
| 377 | // enrichOutcomeWithObjectiveValue computes the objective value for an outcome by fetching |
| 378 | // its associated issue/PR labels and applying the label-to-value mapping. |
| 379 | func enrichOutcomeWithObjectiveValue(report *OutcomeReport, repo string, mapping *github.ObjectiveMapping) { |
| 380 | if report == nil || mapping == nil { |
| 381 | return |
| 382 | } |
| 383 | |
| 384 | // Only compute objective values for items that have a GitHub object number |
| 385 | num := report.ObjectNumber |
| 386 | if num == 0 || repo == "" { |
| 387 | return |
| 388 | } |
| 389 | |
| 390 | // Skip types that don't have associated labels on issues/PRs |
| 391 | if report.Type == "noop" || report.Type == "missing_tool" || report.Type == "missing_data" || report.Type == "report_incomplete" { |
| 392 | return |
| 393 | } |
| 394 | |
| 395 | outcomeEvalLog.Printf("Computing objective value: type=%s, repo=%s, number=%d", report.Type, repo, num) |
| 396 | |
| 397 | resolvedIntent, err := resolveOutcomeIntent(*report, repo, mapping) |
| 398 | if err != nil { |
| 399 | outcomeEvalLog.Printf("Could not trace root for objective value computation: %v", err) |
| 400 | return |
| 401 | } |
| 402 | report.AttributionStatus = string(resolvedIntent.Status) |
| 403 | report.AttributionSource = string(resolvedIntent.Source) |
| 404 | report.TracedRootURL = resolvedIntent.RootURL |
| 405 | |
| 406 | labelNames := resolvedIntent.Labels |
| 407 | if len(labelNames) > 0 { |
| 408 | outcomeEvalLog.Printf("Fetched root labels for %s#%d: root=%s labels=%v", repo, num, resolvedIntent.RootURL, labelNames) |
| 409 | } |
| 410 | |
| 411 | // Compute objective value |
| 412 | objectiveValue := mapping.ComputeObjectiveValue(labelNames) |
| 413 | objectiveLabels := mapping.GetObjectiveLabels(labelNames) |
| 414 | |
| 415 | report.ObjectiveValue = objectiveValue |
| 416 | report.ObjectiveLabels = objectiveLabels |
| 417 | outcomeEvalLog.Printf("Computed objective value for %s#%d: value=%d, labels=%v", repo, num, objectiveValue, objectiveLabels) |
| 418 | } |
| 419 | |
| 420 | func resolveOutcomeIntent(report OutcomeReport, repo string, mapping *github.ObjectiveMapping) (intent.IntentRecord, error) { |
| 421 | resolver := intent.Resolver{ |