evalCreateIssue checks whether an issue was resolved, dismissed, or is still open. Bot-initiated closes (e.g. close-older-issues) are classified as lifecycle, not rejection.
(item CreatedItemReport, repoOverride string)
| 12 | // evalCreateIssue checks whether an issue was resolved, dismissed, or is still open. |
| 13 | // Bot-initiated closes (e.g. close-older-issues) are classified as lifecycle, not rejection. |
| 14 | func evalCreateIssue(item CreatedItemReport, repoOverride string) OutcomeReport { |
| 15 | repo := resolveItemRepo(item, repoOverride) |
| 16 | num := resolveItemNumber(item) |
| 17 | outcomeEvalIssueLog.Printf("Evaluating create_issue: repo=%s, num=%d, url=%s", repo, num, item.URL) |
| 18 | report := OutcomeReport{ |
| 19 | Type: item.Type, |
| 20 | ObjectURL: item.URL, |
| 21 | ObjectNumber: num, |
| 22 | Repo: repo, |
| 23 | } |
| 24 | if num == 0 || repo == "" { |
| 25 | outcomeEvalIssueLog.Printf("Missing issue number or repo: num=%d, repo=%s", num, repo) |
| 26 | report.Result = OutcomeError |
| 27 | report.EvalError = "missing issue number or repo" |
| 28 | return report |
| 29 | } |
| 30 | |
| 31 | data, err := ghAPIGet(fmt.Sprintf("issues/%d", num), repo) |
| 32 | if err != nil { |
| 33 | report.Result = OutcomeError |
| 34 | report.EvalError = err.Error() |
| 35 | return report |
| 36 | } |
| 37 | |
| 38 | state, _ := data["state"].(string) |
| 39 | stateReason, _ := data["state_reason"].(string) |
| 40 | closedAt, _ := data["closed_at"].(string) |
| 41 | |
| 42 | // Count human comments |
| 43 | comments, _ := data["comments"].(float64) |
| 44 | commentList, cerr := ghAPIGetArray(fmt.Sprintf("issues/%d/comments", num), repo) |
| 45 | if cerr == nil { |
| 46 | for _, c := range commentList { |
| 47 | user, _ := c["user"].(map[string]any) |
| 48 | login, _ := user["login"].(string) |
| 49 | if !isBotUser(login) { |
| 50 | report.HumanComments++ |
| 51 | } |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | switch { |
| 56 | case state == "closed" && stateReason == "completed": |
| 57 | report.Result = OutcomeAccepted |
| 58 | report.Detail = "completed" |
| 59 | if closedAt != "" && item.Timestamp != "" { |
| 60 | report.TimeToOutcomeHours = timeBetween(item.Timestamp, closedAt) |
| 61 | } |
| 62 | |
| 63 | case state == "closed" && stateReason == "not_planned": |
| 64 | // Check if closed by a bot (lifecycle) or human (rejection) |
| 65 | closedByBot := isClosedByBot(num, repo) |
| 66 | outcomeEvalIssueLog.Printf("Issue #%d closed as not_planned, closed_by_bot=%v", num, closedByBot) |
| 67 | if closedByBot { |
| 68 | report.Result = OutcomeLifecycle |
| 69 | report.Detail = "closed by bot (lifecycle)" |
| 70 | } else { |
| 71 | report.Result = OutcomeRejected |
nothing calls this directly
no test coverage detected