|
38 | 38 | } |
39 | 39 | } |
40 | 40 |
|
| 41 | + /** |
| 42 | + * Extract a summary from the activity report |
| 43 | + */ |
| 44 | + function extractSummary(body) { |
| 45 | + // Count items in each section |
| 46 | + const commits = (body.match(/^- .+ \(.{7}\) in fvutils\//gm) || []).length; |
| 47 | + |
| 48 | + // Match PRs in the Pull Requests section only |
| 49 | + const prSection = body.match(/### Pull Requests\n([\s\S]*?)(?=\n###|$)/); |
| 50 | + const prs = prSection ? (prSection[1].match(/^- #\d+:/gm) || []).length : 0; |
| 51 | + |
| 52 | + // Build a natural language summary |
| 53 | + const parts = []; |
| 54 | + if (commits > 0) parts.push(`${commits} commit${commits !== 1 ? 's' : ''}`); |
| 55 | + if (prs > 0) parts.push(`${prs} pull request${prs !== 1 ? 's' : ''}`); |
| 56 | + |
| 57 | + if (parts.length === 0) { |
| 58 | + return 'No significant activity this week.'; |
| 59 | + } |
| 60 | + |
| 61 | + const summary = parts.join(' and '); |
| 62 | + return `This week saw ${summary} across FVUtils repositories.`; |
| 63 | + } |
| 64 | + |
41 | 65 | /** |
42 | 66 | * Get excerpt from body text |
43 | 67 | */ |
|
84 | 108 | day: 'numeric' |
85 | 109 | }); |
86 | 110 |
|
| 111 | + const summary = extractSummary(discussion.body); |
| 112 | + |
87 | 113 | html += ` |
88 | 114 | <li class="news-item"> |
89 | 115 | <div class="news-date">${formattedDate}</div> |
90 | | - <h3 class="news-title"><a href="${discussion.html_url}">${discussion.title}</a></h3> |
91 | | - <p class="news-excerpt">${getExcerpt(discussion.body)}</p> |
| 116 | + <h3 class="news-title">${discussion.title}</h3> |
| 117 | + <p class="news-excerpt">${summary} <a href="${discussion.html_url}">View details →</a></p> |
92 | 118 | </li> |
93 | 119 | `; |
94 | 120 | }); |
|
121 | 147 | * Initialize - fetch and render discussions |
122 | 148 | */ |
123 | 149 | async function init() { |
124 | | - const discussions = await fetchDiscussions(); |
125 | | - |
126 | | - if (discussions === null) { |
| 150 | + try { |
| 151 | + const discussions = await fetchDiscussions(); |
| 152 | + |
| 153 | + if (discussions === null || discussions.length === 0) { |
| 154 | + showError(); |
| 155 | + } else { |
| 156 | + renderDiscussions(discussions); |
| 157 | + } |
| 158 | + } catch (error) { |
| 159 | + console.error('Failed to initialize discussions:', error); |
127 | 160 | showError(); |
128 | | - } else { |
129 | | - renderDiscussions(discussions); |
130 | 161 | } |
131 | 162 | } |
132 | 163 |
|
|
0 commit comments