Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1876,10 +1876,9 @@ <h3>Related resources</h3>
} 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;
});
Expand Down
10 changes: 4 additions & 6 deletions tools/catalog-build/build-stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
Loading