(resp *v1pb.CheckReleaseResponse)
| 100 | } |
| 101 | |
| 102 | func buildCommentMessage(resp *v1pb.CheckReleaseResponse) string { |
| 103 | var errorCount, warningCount int |
| 104 | for _, result := range resp.Results { |
| 105 | for _, advice := range result.Advices { |
| 106 | switch advice.Status { |
| 107 | case v1pb.Advice_WARNING: |
| 108 | warningCount++ |
| 109 | case v1pb.Advice_ERROR: |
| 110 | errorCount++ |
| 111 | case v1pb.Advice_ADVICE_LEVEL_UNSPECIFIED, v1pb.Advice_SUCCESS: |
| 112 | // No action needed |
| 113 | default: |
| 114 | // Ignore unknown advice statuses |
| 115 | } |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | var sb strings.Builder |
| 120 | _, _ = sb.WriteString(commentHeader + "\n") |
| 121 | _, _ = sb.WriteString("## SQL Review Summary\n\n") |
| 122 | _, _ = fmt.Fprintf(&sb, "* Total Affected Rows: **%d**\n", resp.AffectedRows) |
| 123 | _, _ = fmt.Fprintf(&sb, "* Overall Risk Level: **%s**\n", formatRiskLevel(resp.RiskLevel)) |
| 124 | _, _ = fmt.Fprintf(&sb, "* Advices Statistics: **%d Error(s), %d Warning(s)**\n", errorCount, warningCount) |
| 125 | _, _ = sb.WriteString("### Detailed Results\n") |
| 126 | _, _ = sb.WriteString(` |
| 127 | <table> |
| 128 | <thead> |
| 129 | <tr> |
| 130 | <th>File</th> |
| 131 | <th>Target</th> |
| 132 | <th>Affected Rows</th> |
| 133 | <th>Risk Level</th> |
| 134 | <th>Advices</th> |
| 135 | </tr> |
| 136 | </thead> |
| 137 | <tbody>`) |
| 138 | for _, result := range resp.Results { |
| 139 | if sb.Len() > maxCommentLength-1000 { |
| 140 | break |
| 141 | } |
| 142 | var errorCount, warningCount int |
| 143 | for _, advice := range result.Advices { |
| 144 | switch advice.Status { |
| 145 | case v1pb.Advice_WARNING: |
| 146 | warningCount++ |
| 147 | case v1pb.Advice_ERROR: |
| 148 | errorCount++ |
| 149 | case v1pb.Advice_ADVICE_LEVEL_UNSPECIFIED, v1pb.Advice_SUCCESS: |
| 150 | // No action needed |
| 151 | default: |
| 152 | // Ignore unknown advice statuses |
| 153 | } |
| 154 | } |
| 155 | counts := []string{} |
| 156 | if errorCount > 0 { |
| 157 | counts = append(counts, fmt.Sprintf("%d Error(s)", errorCount)) |
| 158 | } |
| 159 | if warningCount > 0 { |
no test coverage detected