Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
richmahn committed Apr 11, 2024
1 parent 5198607 commit 8ac0689
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions js/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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('<div class="no-results">'+noResultsText+'</div>');
}
Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit 8ac0689

Please sign in to comment.