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

Fix client stats on empty repos #994

Closed
wants to merge 3 commits into from

Conversation

Kadaaran
Copy link
Contributor

@Kadaaran Kadaaran commented Mar 23, 2018

Fix #912

After pairing with @d12 we've been encountering some issues on Classroom because of the 204.

This is just a first shot as I think I need help about the tests ✋
Is it better to add more tests to check the return value for both 200 and 204 ?
Is the 0 value still ok ? It's based on @kytrinyx 's words:

I would prefer to provide a good zero value that the client code wouldn't have to check

Should it be something else ?

Thank you 🙏

@Kadaaran Kadaaran changed the title Fix client stats on empty repos [WIP] Fix client stats on empty repos Mar 23, 2018
@kytrinyx
Copy link
Contributor

Sorry, I realize that I was using unfamiliar jargon when I said zero value.

For example, a great zero value when there's an array, is an empty array (rather than nil), because then the code will loop over the empty array, and nothing will happen.

In this case, what does the client code expect? What data would let the client code keep doing what it's doing, but essentially be a no-op?

@Kadaaran
Copy link
Contributor Author

Kadaaran commented Mar 23, 2018

@kytrinyx No no no sooorrry it's me ! 🤦‍♀️ First it returned nil but I thought it was a bad idea and I added 0 without actually even thinking about it my bad.

As for us (Classroom) what we do is that we fetch the data and we use the sum method to add all commits from the repository if there is commits. We added a check, so if the answer is nil then we return 0.

I imagine it's not the case for everyone and that an empty array will be easier to deal with 👍

@kytrinyx
Copy link
Contributor

I think that if the response is usually an array, then an empty array would be the cleanest response.

@Kadaaran Kadaaran changed the title [WIP] Fix client stats on empty repos Fix client stats on empty repos Mar 26, 2018
@Kadaaran
Copy link
Contributor Author

@kytrinyx Do you want me to add new specs to it ?

@kytrinyx
Copy link
Contributor

kytrinyx commented Apr 3, 2018

@Kadaaran I'm so sorry I didn't get back to you on this. 🌷

I've taken another look at this, and I can't help but think that the API should never send back a 204, since this is a GET request.

I'm going to chat with @tarebyte about fixing the API rather than changing the response here.

I'll leave this open for now, until we get clarity on the API side.

@Kadaaran
Copy link
Contributor Author

Kadaaran commented Apr 4, 2018

@kytrinyx No worries 🌻

Sure ! Keep me updated if you have amy mews on this subject.

@d12
Copy link

d12 commented Jun 11, 2018

Hey @kytrinyx , is there any movement on this issue?

If not, do you know roughly what timeline we're looking at re: fixing this on the GitHub side? It's breaking Classroom, so if this is going to take time, it'd be great to have a 👍 for merging an octokit hotfix in the meantime. I can take on finishing this PR.

@tarebyte
Copy link
Member

@d12 there isn't really any movement on this right now, feel free to take on the PR 😄

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.

4 participants