From 056b09fcbb0c32881003b42137625f61485612bf Mon Sep 17 00:00:00 2001 From: squidfunk Date: Fri, 5 Feb 2016 15:31:44 +0100 Subject: [PATCH] Fixed error in fetching stargazer count --- src/assets/javascripts/application.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/assets/javascripts/application.js b/src/assets/javascripts/application.js index d730c58a6..29df5c216 100644 --- a/src/assets/javascripts/application.js +++ b/src/assets/javascripts/application.js @@ -503,12 +503,14 @@ document.addEventListener('DOMContentLoaded', function() { * ------------------------------------------------------------------------- */ /* Get Stars for current repository */ - pegasus('https://api.github.com/repos/' + repo_id + '/stargazers').then( + pegasus('https://api.github.com/repos/' + repo_id).then( /* Request successful, we got the stars */ function(data, xhr) { - var count = data.length; - if (count > 1000) + var count = data.stargazers_count; + if (count > 10000) + count = (count / 1000).toFixed(0) + "k"; + else if (count > 1000) count = (count / 1000).toFixed(1) + "k"; /* Set number of stars */