From deba31634b9622718a55f28c05ffd194ba6a3a53 Mon Sep 17 00:00:00 2001
From: soyalejolopez <88358406+soyalejolopez@users.noreply.github.com>
Date: Wed, 22 Jul 2026 13:12:15 -0500
Subject: [PATCH] Fix Engaging sort to rank by reaction count
The Engaging sort used a smoothed upvotes-per-view rate, which buried high-traffic resources so a resource with many views and a single reaction never surfaced. Rank by raw reaction/upvote count (views as tiebreaker, then name) so reactions drive the sort as expected.
Also count all GitHub Discussion reaction types (not just THUMBS_UP) when computing upvotes in build-stats.js, so any reaction registers.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 8ee4765a-3082-46e1-8848-c29193ffd00f
---
index.html | 7 +++----
tools/catalog-build/build-stats.js | 10 ++++------
2 files changed, 7 insertions(+), 10 deletions(-)
diff --git a/index.html b/index.html
index 329a4f8..0b21c7f 100644
--- a/index.html
+++ b/index.html
@@ -1876,10 +1876,9 @@
Related resources
} else if (state.sort === 'new') {
return new Date(b.updated) - new Date(a.updated);
} else if (state.sort === 'engaging') {
- const rateA = (statsA.upvotes + 2) / (statsA.views + 40);
- const rateB = (statsB.upvotes + 2) / (statsB.views + 40);
- if (rateB !== rateA) return rateB - rateA;
- return statsB.upvotes - statsA.upvotes;
+ if (statsA.upvotes !== statsB.upvotes) return statsB.upvotes - statsA.upvotes;
+ if (statsA.views !== statsB.views) return statsB.views - statsA.views;
+ return a.name.localeCompare(b.name);
}
return 0;
});
diff --git a/tools/catalog-build/build-stats.js b/tools/catalog-build/build-stats.js
index e498a5b..4bd5113 100644
--- a/tools/catalog-build/build-stats.js
+++ b/tools/catalog-build/build-stats.js
@@ -325,12 +325,10 @@ function mapDiscussions(discussions, knownSlugs, explicitMap) {
discussions.find(item => item.title.includes(slug));
}
if (!discussion) continue;
- const thumbsUp = discussion.reactionGroups?.find(group => group.content === 'THUMBS_UP');
- const count = thumbsUp?.reactors?.totalCount;
- if (!Number.isInteger(count) || count < 0) {
- console.warn(`Warning: discussion #${discussion.number} has no THUMBS_UP count.`);
- continue;
- }
+ const count = (discussion.reactionGroups ?? []).reduce((sum, group) => {
+ const total = group?.reactors?.totalCount;
+ return sum + (Number.isInteger(total) && total > 0 ? total : 0);
+ }, 0);
result.set(slug, {
upvotes: count,
discussion: { number: discussion.number, url: discussion.url }