Giter Site home page Giter Site logo

Comments (10)

edswf1 avatar edswf1 commented on July 20, 2024

i'll take a look at the github api

from dogecoin.com.

nickatnight avatar nickatnight commented on July 20, 2024

@edswf1 there should be a JS wrapper for their api that supports this right out the box...here

Unless @patricklodder prefers an in house solution to decrease the amount of libs we are loading

from dogecoin.com.

edswf1 avatar edswf1 commented on July 20, 2024

@edswf1 there should be a JS wrapper for their api that supports this right out the box...here

Unless @patricklodder prefers an in house solution to decrease the amount of libs we are loading

i don't think a library is needed, this simple function should do it:

function getFromGHAPI(source){
  let baseUrl = 'https://api.github.com/repos/dogecoin/dogecoin/';
  $.get(baseUrl + source + '?per_page=1').done(function(ret, responseText, jqXHR){
    try{
      var linkText = jqXHR.getResponseHeader('link');
      var last = linkText.split(',')[1];
      var count = last.split('&page=')[1].replace(/[^0-9]+/, '');
      console.log(count);
    }
    catch(e){
      console.error(e);
    }
  });
}
getFromGHAPI('commits'); //get number of commits -> 13532
getFromGHAPI('forks'); //get number of forks -> 1157
getFromGHAPI('releases'); //get number of releases -> 36
getFromGHAPI('contributors'); //get number of forks -> 349

in Detail:
when per_page parameter is set, GH API returns a 'link' response header with next and last page. As we request only one item per page, the number of the last page is also the number of total elements available by GH API.

This is apparently not what GH uses to display numbers in the repository as there are 201 Contributors and 159 Releases there.

Edit: Seems like only published releases are available through GH API. No idea about contributors count though. But hey, numbers are close to the truth ;)

Edit 2: as GH API Limits Calls to 60/h/IP, a fallback and caching of those numbers would be needed

from dogecoin.com.

nickatnight avatar nickatnight commented on July 20, 2024

@edswf1 wow this is real elegant. Great job!

as GH API Limits Calls to 60/h/IP, a fallback and caching of those numbers would be needed

Local Storage my guy

from dogecoin.com.

edswf1 avatar edswf1 commented on July 20, 2024

Local Storage my guy

true. i was just trying to say that the function is by no means complete yet

from dogecoin.com.

nickatnight avatar nickatnight commented on July 20, 2024

Hmm actually I'm not sure that would work because traffic to the site definitely has potential for more than 60 users per hour. Maybe create some routine to write those metrics your functions pull into a readable assets file? Then read those values and display.

Then, I think we can use local storage to prevent reading from file on every page load.

We could actually take this a step further and create a github action to write those stats to file based on some trigger...but that's probably too brute force for right now. I'd like to hear input from others first.

from dogecoin.com.

edswf1 avatar edswf1 commented on July 20, 2024

Hmm actually I'm not sure that would work because traffic to the site definitely has potential for more than 60 users per hour.

As i understood, this limit is per client IP. I think putting current values as a fallback would cover most errors then

from dogecoin.com.

nickatnight avatar nickatnight commented on July 20, 2024

As i understood, this limit is per client IP

Oh ok per client ip..yeah that should be fine

from dogecoin.com.

magneticat avatar magneticat commented on July 20, 2024

Am I wrong in assuming that due to the way Dogecoin Core is being developed such a graphic would not reflect the real amount of work being done on Doge? Patrick or Sporklin mentioned on r/dogecoindev (cannot find the thread now, thanks to reddit's beautiful search) that the github repo shows little activity because they develop the major releases in a repository not linked directly to github.

Correct me if I am wrong!

from dogecoin.com.

nickatnight avatar nickatnight commented on July 20, 2024

@magneticat I'm not actually sure about that! But where ever the repo lays, I'm sure we can pull stats from it. @patricklodder savvy?

from dogecoin.com.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.