IonicaBizau / cli-gh-cal

:chart_with_upwards_trend: GitHub like calendar graphs in command line.
MIT License
36 stars 5 forks source link

Incorrect streak calculation #29

Closed csabaxyz closed 5 years ago

csabaxyz commented 5 years ago

Hey, I've been looking for a way to check my commit streak for my local git repos, and that's when I found your git-stats repo.

However, I found that the streak calculation was incorrect, as it was reported here: https://github.com/IonicaBizau/git-stats/issues/88

I checked the function calls, and as it turns out, in the end git-stats calls the CliGhCal function in this package.

Take a look at the following example:

./bin/cli-gh-cal -d '[
  ["2019 Feb 2",2],
  ["2019 Feb 3",2],
  ["2019 Feb 4",5],
  ["2019 May 1",1],
  ["2019 May 2",5]
]'

This will tell me that the Current Streak is 5, however today is May 5, and the last commit is May 2. Also, it says that the Longest Streak is 5. There are 5 commits in all, and the longest should be 3.

The problem is that when you calculate the streak the dates are not necessarily continuous, see my example above.

But it is a simple fix, so I'm going to send a pull request in a minute. :)

IonicaBizau commented 5 years ago

Thanks for this! Will check your PR soon! :+1: