Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Contributors along with their avatars showing up on multi-repository view. #54

Merged
merged 1 commit into from
Oct 8, 2018

Conversation

Rishabh570
Copy link
Collaborator

Fixes #29

@Rishabh570 Rishabh570 changed the title Contributors along with their avatars showing up on multi-repository view. [WIP] Contributors along with their avatars showing up on multi-repository view. Oct 4, 2018
@jywarren
Copy link
Member

jywarren commented Oct 4, 2018 via email

@Rishabh570
Copy link
Collaborator Author

@jywarren I open this work in progress PR.
There are some small things to be fixed in this, but most of the work is done.
What I've done is, fetch all the repos and then store all the unique contributors from all these repos (currently first 30 repos), and store them in localStorage, so that with a page reload we don't hit Github API redundantly and use localStorage instead...

Once I fix some remaining things, I'll post a screenshot of it :)

@jywarren
Copy link
Member

jywarren commented Oct 4, 2018 via email

@jywarren
Copy link
Member

jywarren commented Oct 4, 2018

👍 This is one of my top bugs I'd like to see fixed, so thank you in advance!!!

var testRepos = repos.splice(0,2);
testRepos.map((repo, i) => {
var repoContributors = fetchRepoContributors(org, repo);
console.log("total contributors for repo ", i, "are : ", repoContributors ,repoContributors.length, '\n')
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, repoContributors.length is 0 while repoContributors has objects in it...What is the reason for this behaviour??

@Rishabh570
Copy link
Collaborator Author

@jywarren I was stuck onto something (implementing promises, using async/await) but none seem to work out...For now I get it to work with the help of setTimeout function which also achieves what we want except that opening https://code.publiclab.org for the first will take a while to load contributors (approx 20sec) but after that it will never hit Github API for loading contributors again (as long as localstorage is not cleared out)...

screenshot from 2018-10-05 17-08-40

Please take a look :)

@jywarren
Copy link
Member

jywarren commented Oct 5, 2018 via email

Copy link
Member

@jywarren jywarren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very cool!!!!! I asked a few questions and made one suggestion :-)

})


return new Promise((resolve, reject) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so you did end up using promises? cool!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I used them but things didn't happen the way I thought, so I ended up putting up setTimeout everywhere...(async/await are not allowed by grunt-browserify, it is giving error while grunt build)

res.map((item, i) => {
repos[i] = item.name;
});
// Stores all public lab repos to localstorage (only first 30 repos yet)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could become a new follow-up issue 👍

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, currently fetching publiclab's repos only gives the repos listed on 1st page...

});
}
// Stores all unique contributors info to localstorage
localStorage.setItem('contributors', JSON.stringify(myArr));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting! When would this then get flushed and updated? Could we do once daily? And could we implement this via a flushLocalStorageAllContributors or something... so we could manually refresh it with a 🔄 button or something?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, the only way to request the API again for contributors is by manually flushing localStorage...but this can easily done, so no worries :)

@jywarren
Copy link
Member

jywarren commented Oct 5, 2018

Also, I'd love to have contributors listed with @ so they can be quickly copied and pasted.

@Rishabh570
Copy link
Collaborator Author

Updating it 😸

@jywarren
Copy link
Member

jywarren commented Oct 5, 2018 via email

@Rishabh570
Copy link
Collaborator Author

Yes, its possible...so should I implement it?

@Rishabh570
Copy link
Collaborator Author

@jywarren I've added the logic for removing contributors data from localStorage after every single day...please take a look :)

@jywarren
Copy link
Member

jywarren commented Oct 5, 2018

This looks great. Did you want to try to push this into your gh-pages branch so we can try it before merging, OR post a screenshot gif using the peek or licecap programs?

We should look ahead to tests as well so we don't have to be so tentative :-)

Thank you!!!! 👍

@Rishabh570
Copy link
Collaborator Author

Hi @jywarren , sorry for delay, actually I made gif 3 times but it gets bigger than 10mb everytime and I keep hitting the API limits regularly while testing...

I'll create another gif as my API quota gets refilled 😅

@Rishabh570
Copy link
Collaborator Author

@jywarren Here is the working GIF,

ezgif com-optimize

@jywarren
Copy link
Member

jywarren commented Oct 6, 2018

Ok awesome. Why 20 seconds, precisely? Just waiting for all results to come in? Could we display them as they arrive? It does seem a little long to wait I guess with no feedback.

Also, perhaps if we're waiting we should add a spinner icon - fontawesome has a <i class="fa fa-spinner fa-spin"></i> icon class you could use. What do you think?

@Rishabh570
Copy link
Collaborator Author

@jywarren I've given 20seconds to setTimeout, that's why it takes 20sec to render contributors...anyways I am working on reducing the render time and I'll add spinner icon if render time still remains significant

@Rishabh570
Copy link
Collaborator Author

@jywarren Finally, removed setTimeout from everywhere...implemented promises instead 😅
I'll be sharing a working GIF (as my API quota gets refilled)

@Rishabh570
Copy link
Collaborator Author

@jywarren Here it is, it doesn't take 20seconds anymore 😂 Probably 2-3 seconds...

working_promises

@jywarren
Copy link
Member

jywarren commented Oct 7, 2018

This is fantastic. Do you think it's ready to merge?

@Rishabh570
Copy link
Collaborator Author

Yes, only if we don't need spinner icon for now...

@Rishabh570
Copy link
Collaborator Author

@jywarren what do you think...do we need a spinner icon?

@jywarren
Copy link
Member

jywarren commented Oct 8, 2018

Let's do spinner in a follow up. Would you mind opening an issue?

Merging! I'll publish soon :-)))

Great work!!!!

@jywarren jywarren merged commit 6417542 into publiclab:master Oct 8, 2018
@welcome
Copy link

welcome bot commented Oct 8, 2018

Congrats on merging your first pull request! 🙌🎉⚡️
Your code will likely be published to code.publiclab.org in the next few days.
In the meantime, can you tell us your Twitter handle so we can thank you properly?
Now that you've completed this, you can help someone else take their first step! See: https://code.publiclab.org

@jywarren
Copy link
Member

jywarren commented Oct 8, 2018

Hi, @Rishabh570 -- just another thought here -- does this properly remember to show individual contributors when you go to:

http://code.publiclab.org

after you first go to http://code.publiclab.org#r=all ?

@Rishabh570
Copy link
Collaborator Author

@jywarren Yes, because there are the separate functions for both of the views...I will post a GIF anyways :)

@Rishabh570
Copy link
Collaborator Author

Let's do spinner in a follow up. Would you mind opening an issue?
Yep, I'll open an issue for it :)

@Rishabh570
Copy link
Collaborator Author

Here is GIF showing a separate list of contributors on both the pages...

ezgif com-optimize 1

@jywarren
Copy link
Member

Fantastic! I think in testing it i blew through my API limit :-P

I'll move to #53 for that though. (including error for ref)

GREAT WORK again!

Failed to load resource: the server responded with a status of 403 (Forbidden)
:8000/#r=all:1 Uncaught (in promise) StatusCodeErrorerror: {message: "API rate limit exceeded for 113.110.231.235. (But …t. Check out the documentation for more details.)", documentation_url: "https://developer.github.com/v3/#rate-limiting"}message: "403 - [object Object]"name: "StatusCodeError"options: {baseUrl: "https://api.github.com", headers: {…}, json: true, method: "GET", qs: {…}, …}response: exports.IncomingMessage {_readableState: ReadableState, readable: false, _events: {…}, _eventsCount: 4, _maxListeners: undefined, …}statusCode: 403isOperational: truestack: "StatusCodeError: 403 - [object Object]↵    at new StatusCodeError (http://localhost:8000/dist/community-toolbox.js:63719:15)↵    at Request.RP$callback [as _callback] (http://localhost:8000/dist/community-toolbox.js:63800:32)↵    at Request.self.callback (http://localhost:8000/dist/community-toolbox.js:65543:22)↵    at emitTwo (http://localhost:8000/dist/community-toolbox.js:31148:13)↵    at Request.emit (http://localhost:8000/dist/community-toolbox.js:31219:7)↵    at Request.<anonymous> (http://localhost:8000/dist/community-toolbox.js:66519:10)↵    at emitOne (http://localhost:8000/dist/community-toolbox.js:31138:13)↵    at Request.emit (http://localhost:8000/dist/community-toolbox.js:31216:7)↵    at exports.IncomingMessage.<anonymous> (http://localhost:8000/dist/community-toolbox.js:66441:12)↵    at Object.onceWrapper (http://localhost:8000/dist/community-toolbox.js:31319:30)↵    at emitNone (http://localhost:8000/dist/community-toolbox.js:31133:20)↵    at exports.IncomingMessage.emit (http://localhost:8000/dist/community-toolbox.js:31213:7)↵    at endReadableNT (http://localhost:8000/dist/community-toolbox.js:62592:12)↵    at afterTickTwo (http://localhost:8000/dist/community-toolbox.js:59159:10)↵    at Item.run (http://localhost:8000/dist/community-toolbox.js:59332:14)↵    at drainQueue (http://localhost:8000/dist/community-toolbox.js:59302:42)"__proto__: Error

@jywarren
Copy link
Member

I think the new code uses the limit really fast so the "exhausted" message and localstorage will be much needed.

BTW we'd love to thank you on Twitter if you wanted to share your handle on there? 🎉

@Rishabh570
Copy link
Collaborator Author

"exhausted" message and localstorage will be much needed.

yes, I do believe that...that's why storing the data is the only best option :)

BTW we'd love to thank you on Twitter if you wanted to share your handle on there?

Thats so nice 😸 It is rishabh_570

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants