MCPcopy Create free account
hub / github.com/github/gh-aw / computeValueFirst

Method computeValueFirst

pkg/github/label_objective_mapping.go:88–107  ·  view source on GitHub ↗

computeValueFirst returns the value for the first issue label that appears in PriorityLabels. It iterates issueLabels in their existing order and returns the value for the first one found in PriorityLabels; if none match, it falls back to the first value in matchingValues.

(issueLabels []string, matchingValues []int, matchedLabels []string)

Source from the content-addressed store, hash-verified

86// It iterates issueLabels in their existing order and returns the value for the first one
87// found in PriorityLabels; if none match, it falls back to the first value in matchingValues.
88func (om *ObjectiveMapping) computeValueFirst(issueLabels []string, matchingValues []int, matchedLabels []string) int {
89 // Return first issue label that's in priority_labels
90 if len(om.PriorityLabels) > 0 {
91 for _, issueLabel := range issueLabels {
92 for _, priorityLabel := range om.PriorityLabels {
93 if strings.EqualFold(issueLabel, priorityLabel) {
94 normalizedIssue := strings.ToLower(strings.TrimSpace(issueLabel))
95 if val, ok := om.LabelToValue[normalizedIssue]; ok {
96 labelObjectiveMappingLog.Printf("Computed objective value via issue label priority: label=%s, value=%d", issueLabel, val)
97 return val
98 }
99 }
100 }
101 }
102 }
103 // Fallback to first matching label
104 result := matchingValues[0]
105 labelObjectiveMappingLog.Printf("Computed objective value via first match: labels=%v, value=%d", matchedLabels, result)
106 return result
107}
108
109// computeValueMax returns the highest value among all matching labels.
110func (om *ObjectiveMapping) computeValueMax(matchingValues []int, matchedLabels []string) int {

Callers 1

ComputeObjectiveValueMethod · 0.95

Calls 2

ToLowerMethod · 0.80
PrintfMethod · 0.45

Tested by

no test coverage detected