Skip to content

Commit 7842079

Browse files
committed
Improve weekly update display with smart summaries
- Extract activity counts (commits, PRs) from markdown - Display clean one-line summary instead of raw markdown - Add 'View details →' link to full discussion - Show multiple weekly updates properly - Better error handling
1 parent 3dc3de9 commit 7842079

1 file changed

Lines changed: 38 additions & 7 deletions

File tree

public/js/discussion-feed.js

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,30 @@
3838
}
3939
}
4040

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+
4165
/**
4266
* Get excerpt from body text
4367
*/
@@ -84,11 +108,13 @@
84108
day: 'numeric'
85109
});
86110

111+
const summary = extractSummary(discussion.body);
112+
87113
html += `
88114
<li class="news-item">
89115
<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>
92118
</li>
93119
`;
94120
});
@@ -121,12 +147,17 @@
121147
* Initialize - fetch and render discussions
122148
*/
123149
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);
127160
showError();
128-
} else {
129-
renderDiscussions(discussions);
130161
}
131162
}
132163

0 commit comments

Comments
 (0)