Coder Social home page Coder Social logo

Comments (25)

wbraswell avatar wbraswell commented on June 15, 2024 1

@Naramsim

Yes that sounds great! I think a Fiddle which updates GitHub gists is the best plan.

You only need to store the date on which the user has started their current streak, so it is just 2 pieces of data: username and current_streak_start_date.

Once it works for just the username & current_streak_start_date, then it may be possible to add such items as longest_streak_start_date and longest_streak_end_date.

from githuboriginalstreak.

wbraswell avatar wbraswell commented on June 15, 2024 1

Okay if the extension can edit the gist, then you can update the streak start date whenever user views their Github home page.
I think we may need to actually have 2 dates saved in the gist for each user: "current streak start date", and "saved streak start date". If there is a gap in work during the past year, then the "current streak start date" is copied into the "saved streak start date", and the current date is then set to 0 or null, which causes the user to see a smaller-or-0-day streak. If the gap in work is later filled by a git push from a different repo, then the "saved streak start date" can be copied into the "current streak start date", which causes the user to see their long streak again.

from githuboriginalstreak.

wbraswell avatar wbraswell commented on June 15, 2024 1

@Naramsim
Okay great, I look forward to v1.9 tomorrow, I will let you know if I see any mistakes in calculation.

Yes, I think it would be a great help to show a balloon message to invite users to select a custom start date once they reach 1 full year. :-)

from githuboriginalstreak.

wbraswell avatar wbraswell commented on June 15, 2024 1

@Naramsim
Yes you may, although I would strongly prefer we wait 2 more days until I hit 700 days! :-D

from githuboriginalstreak.

wbraswell avatar wbraswell commented on June 15, 2024

Ah, I see this is a mostly-duplicate of "Current streak error when full year of contributions":
#22

I also see that you have a partial solution already developed:
https://jsfiddle.net/m18vkLdo/

I can prove my current streak with both a dated Github screenshot (attached to this comment), as well as with the full .git/ directories of all applicable repositories if you like (not attached).

wbraswell_20160326-github_streak_600_cropped

May I please respectfully request that you enter my Github account into the JSFiddle solution to maintain my correct code streak? Thanks!

from githuboriginalstreak.

Naramsim avatar Naramsim commented on June 15, 2024

GitHub:

Only events created within the past 90 days will be included in timelines. Events older than 90 days will not be included (even if the total number of events in the timeline is less than 300).

So we cannot get previous contributions using Github API.
Basically, Github only lets you see users activities starting from three days ago (a normal user has more than 300 events in three days). So we can't use that fiddle to get our data.

We could perform a daily check if the streak is >373, then, if you have made a commit that day, store a variable to increase the streak. But this would require you to use GithubOriginalStreak extension every day. And the correct streak value would be seen only by the user since we do not use any kind of database.

So I can't figure out how to solve this problem. Any suggestion? @wbraswell

from githuboriginalstreak.

wbraswell avatar wbraswell commented on June 15, 2024

@Naramsim
Thank you for your reply!

We need some very simple web-based mechanism for storing and updating the "current streak start date" for each user who has as streak over 1 year long. As you call it, we need a "database", although it does not actually need to be a full SQL database, we really just need some simple online data storage.

Each user with a current streak longer than 1 year will need to intentionally "opt in" to this feature by submitting to you some proof of their current streak, at which point you can create an entry for that user in the online data storage.

I suggest using Github itself as the free online data storage mechanism, we can use flat text files stored in a special Github repo and use the Github API to read and update the files as needed:
https://developer.github.com/v3/repos/contents/

One obvious solution is to simply create a plain text file with the same name as the Github username (for me the file would be named "wbraswell" or "wbraswell.txt"), and each file only has 1 line of data which is the current streak start date, we can call this the user's "streak file". This should be quite easy to read and update via the Github API. The browser extension can simply check the Github API to see if a streak file exists for the current user, if so then their current start date is read and utilized, if not then it is assumed they have a current streak of less than 1 year and the existing code is utilized.

I believe this solution should be relatively straightforward to implement, free of cost, and stable based on flat files in a Github repository. However, I am not a Javascript programmer, so can you tell me if this is a good and logical solution?

Thanks! :-)

from githuboriginalstreak.

Naramsim avatar Naramsim commented on June 15, 2024

ok, I made a Fiddle that updates GitHub gists 😄
But a problem still remains: to add days to the streak you have to use the extension every day.

Or we can store the date in which the user has started the streak...
So I will store "18/04/2013", and for the streak I will display now() - "18/04/2013"

from githuboriginalstreak.

Naramsim avatar Naramsim commented on June 15, 2024

@wbraswell When you think your streak has started? (I've setted 2010-06-28)
This is the gist: https://gist.github.com/Original-Streak/5d89d59e4e9355ff5e8316b40dcebf09

As now the extension does this:

If the user has a complete calendar (full streak) it checks if in the gist does appear a custom starting date.
If there is a custom starting date, it uses that one.
If there isn't, it sets the very first day of the calendar as the custom starting date.
If the user has set a custom starting date, and for some reason does not contribute for two days, it removes the custom start date. So be careful, after two non-committing days, your streaks are reset to 367 days.

What do you think? Chrome will update the extension in a day, ff in a week like Opera. Which browser are you using?

from githuboriginalstreak.

wbraswell avatar wbraswell commented on June 15, 2024

@Naramsim
Wow awesome work, I am showing that you have put Jun 28, 2010 as my start date, so it seems to be working!

According to my Github screenshot which I have attached to my post 3 days ago, my true streak started on August 5, 2014.

I am currently using the Github Original Streak browser extension in:
Chromium 50.0.2661.102 (Developer Build) Ubuntu 14.04 (64-bit).

I also have the following 2 browsers, but I am not using the extension with them right now:
Google Chrome 40.0.2214.95 (Official Build)
Mozilla Firefox for Ubuntu 47.0 canonical 1.0

I have 3 questions about your logic:

  1. If the user breaks their streak, then it should reset to 0 days instead of 367 days, correct?
  2. Example: If the has 2 different repositories A & B, then some of the repo A commits with dates of today may be pushed to github before repo B commits with dates from last week, which means that it would seem like the user has broken their streak until they push the commits from repo B. This means the Github Original Streak browser extension will need to be smart enough to first tell the user they are down to 0 days, then after repo B commits are pushed the browser extension needs to tell the user they are back up to their long current streak, correct? (This is the same way the original Github software worked.)
  3. Example: If the user does not push any commits to Github for 1 whole week then they should be shown as having a streak of 0 days, but if they then push commits which include dates from all missing days, then again the browser extension should be smart enough to switch them back to their current streak, similar to question 2 above, correct?

Thanks!

from githuboriginalstreak.

Naramsim avatar Naramsim commented on June 15, 2024

1: They will be calculated normally. Longest streak: around 365 days Current streak: 0
2. Seems hard to do, will see
3. Correct, how to handle this case (which is simpler that the upper one)? Maybe just by don't delete the custom start date. But if I don't delete the custom start date this case could happen:

a user has a full streak, it does not commit a day. A year passes and the calendar in now full of contributions again. The user now has a streak of two years, because the custom start date wasn't deleted.

How can we manage it?

from githuboriginalstreak.

wbraswell avatar wbraswell commented on June 15, 2024

Does the browser extension check the Github gist every single time the user views their Github home page? If so, then it should be relatively straightforward to simply update the gist every time the extension is used, but only if the gist needs to be updated of course.

Or is the browser extension relying on some outside mechanism (like the JS Fiddle) in order to update the gist exactly 1 time per day, independent of how many times the user views their Github home page?

from githuboriginalstreak.

Naramsim avatar Naramsim commented on June 15, 2024

The gist is modified directly by the extension when any user browses a profile with full contributions. At least it checks if for that profile a custom start date was set

from githuboriginalstreak.

wbraswell avatar wbraswell commented on June 15, 2024

Does the browser extension have the ability to edit the gist to modify the streak start date, or can the browser extension only read the gist without editing it?

from githuboriginalstreak.

Naramsim avatar Naramsim commented on June 15, 2024

It can read and write (that leads to security issues, so one can delete everything, but since this is a free opensource project why someone should do it?)

from githuboriginalstreak.

Naramsim avatar Naramsim commented on June 15, 2024

@wbraswell Done. Now we have a sort of backup.
The new version 1.9 that will roll out tomorrow is incompatible with the current one(1.8).
So there could be some mistakes in calculation tomorrow

PS: I was thinking that maybe I could show a balloon/message to the users with full calendar inviting them to select a custom start date. What do you think?

from githuboriginalstreak.

wbraswell avatar wbraswell commented on June 15, 2024

@Naramsim

My browser is telling me it has disabled the extension because it requires new permissions:

"Read & change your data on api.github.com and github.com."

Why does the extension need to change my own github data? I thought the gist was stored in your repo only?

from githuboriginalstreak.

Naramsim avatar Naramsim commented on June 15, 2024

That means that the extension operates on those domain. Github.com was already there, i've added api.github.com because i need to call github api. I cant update the gist without those permissions.

from githuboriginalstreak.

wbraswell avatar wbraswell commented on June 15, 2024

Oh okay, so it is not trying to modify MY github account or repos, only YOUR github info?

from githuboriginalstreak.

Naramsim avatar Naramsim commented on June 15, 2024

Basically it says that I can read (and modify) the HTML on github.com and api.github.com
No security issues 😄

from githuboriginalstreak.

wbraswell avatar wbraswell commented on June 15, 2024

Okay but again, this is only modifying the data on YOUR github account, not on MY github account, correct?

from githuboriginalstreak.

Naramsim avatar Naramsim commented on June 15, 2024

For sure

from githuboriginalstreak.

Naramsim avatar Naramsim commented on June 15, 2024

I cannot in any way access to your Github account.

from githuboriginalstreak.

wbraswell avatar wbraswell commented on June 15, 2024

Okay great, thanks! :-)

from githuboriginalstreak.

Naramsim avatar Naramsim commented on June 15, 2024

Can I put a screenshot of your profile on the chrome web store? @wbraswell

from githuboriginalstreak.

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.