From 8ac0689c20455aebe6b86dd70d07f0d789d43a93 Mon Sep 17 00:00:00 2001 From: Richard Mahn Date: Wed, 10 Apr 2024 20:43:34 -0600 Subject: [PATCH] Fixes --- js/i18n.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/js/i18n.js b/js/i18n.js index 2d43f5c..44a2cf8 100644 --- a/js/i18n.js +++ b/js/i18n.js @@ -734,6 +734,9 @@ function updateRecentResults(err, entries) { */ function updateSearchResults(searchType, err, entries) { if (!err) { + entries.forEach(entry => { + entry.views = entry.stars_count + entry.forks_count + entry.watchers_count; + }); if(!searchType) { searchResults[SECTION_TYPE_RECENT] = entries.slice(); searchResults[SECTION_TYPE_POPULAR] = entries; @@ -834,7 +837,7 @@ function showSearchResults(sectionToShow) { $popular_div.empty(); } var popularResults = searchResults[SECTION_TYPE_POPULAR]; - popularResults = _.sortBy(popularResults.reverse(), 'num_stars').reverse(); // Reverse 1st time since we reverse again + popularResults = _.sortBy(popularResults.reverse(), 'views').reverse(); // Reverse 1st time since we reverse again if (!popularResults.length) { $popular_div.html('
'+noResultsText+'
'); } @@ -931,7 +934,7 @@ function showThisItem(item, $div, template) { var langName = getSubItem(item, ['language_title']); var langCode = getSubItem(item, ['language']); $template.find('.language-code-div').html(simpleFormat(langAndCodeFormat, [langName, langCode])); - var views = parseInt(getSubItem(item, ['stars_count'])) + parseInt(getSubItem(item, ['watchers_count'])) + parseInt(getSubItem(item, ['forks_count'])); + var views = getSubItem(item, ['views']); $template.find('.views-span').html(views); var lastUpdated = getSubItem(item, ['updated_at'], '1970-01-01'); $template.find('.updated-span').html(getDateDiff(lastUpdated, today));