Coder Social home page Coder Social logo

Negative star count about star-history HOT 4 CLOSED

star-history avatar star-history commented on May 16, 2024
Negative star count

from star-history.

Comments (4)

chinesedfan avatar chinesedfan commented on May 16, 2024 1

It should be caused by someone revoked the star after starred. I noticed starred_url, i.e. "https://api.github.com/users/nschlemm/starred{/owner}{/repo}" , but seems it doesn't work. And I didn't find a good v3 API to solve this problem.

StargazerConnection in v4, should be more powerful. Combining with other APIs, we can even solve #31.

from star-history.

nosarthur avatar nosarthur commented on May 16, 2024

https://star-history.t9t.io/#nosarthur/gita

I put in one of my project and it also has -30 stars in the beginning

from star-history.

timqian avatar timqian commented on May 16, 2024

@chinesedfan Thanks for finding the root cause, I will check it out when I got time.

To my experience, people don't unstar projects very often, so this seems not a big issue for me. We can find a workaround first and then consider if it worth the effort to migrate to GitHub API v4

from star-history.

chinesedfan avatar chinesedfan commented on May 16, 2024

@timqian After a night's thinking, I realized the real reason was something wrong in the codes.

// used to calculate total stars for this page
const pageIndexes = pageNum <= sampleNum ?
  range(pageNum).slice(1, pageNum) :
  range(sampleNum).map(n => Math.round(n / sampleNum * pageNum) - 1); // for bootstrap bug

// ...
starHistory = pageIndexes.map((p, i) => {
  return {
    date: resArray[i + 1].data[0].starred_at.slice(0, 10),
    starNum: 30 * (p - 1),
  };
});

Math.round is not a stable method, which means it may select a smaller or larger value. Sometimes pageIndexes will include 0 as the first element. That's why -30 is generated.

And I also find another place that using Math.round. A better way should only consider the day part of new Date() and calculate daysSinceRepoCreatedAt by Math.ceil.

const daysSinceRepoCreatedAt = Math.round((new Date()) - firstStarredAt) / (1000*60*60*24);

from star-history.

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.