-
Notifications
You must be signed in to change notification settings - Fork 569
Dashboard for Teachers (time of the last push & build status) #708
Conversation
Currently, this function will cost a lot of time for the pages to load, I'll change the implementations using AJAX. |
Hey @cyhsutw how close is this to being finished? I'd love to see this get merged, it looks great from what I can see. |
Closing for now, feel free to re-open if there's progress. |
@nwoodthorpe Thanks for the heads-up. I've merged |
@@ -52,7 +52,9 @@ | |||
end | |||
|
|||
after(:build) do |organization, evaluator| | |||
create_list(:user, evaluator.users_count, organizations: [organization]) | |||
if evaluator.users.count < evaluator.users_count | |||
create_list(:user, evaluator.users_count, organizations: [organization]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added this check because this is adding random extra users to the organization.
This will break the functionality of Organization#github_client
since the access_token
of the randomly created user is not valid, which will make the API calls return 401.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, could you explain this a bit more? What's creating random users in the organization?
Having to edit this random unrelated line of code that's been fine for 2 months worries me a little bit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll try my best to explain it.
So this line of code will generate a list of users with length equals to evaluator.users_count
, and the users are generated using this factory.
This is totally okay if we don't access any of the users generated by this line of code (and yes, there isn't a line in the codebase that does this). However, if we try to use any of the access tokens that are associated with these users to call GitHub APIs, it simply fails as these are just some random hex string.
This line of code will create a new user even if we already specified users to be associated with the organization (e.g. GitHubFactory#classroom_org).
This is the issue I faced when I run test examples:
let(:organization) { classroom_org }
# => organization.users.size <--- this is 2!
In this case, you can only get a working organization.github_client on a 50% chance.
IMHO the reason we have this line of code is to ensure that there's at least one user in an organization, we don't need to add another user if we already got one. That's the reason I made this change.
Please let me know if there's anything I can help. Thanks! 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, because a token is chosen from a random user. In that case, this makes sense to me.
Thanks for getting this sorted! It's a pretty hefty diff, I'll try to find some time today to step through it. |
@@ -0,0 +1,41 @@ | |||
# frozen_string_literal: true | |||
|
|||
module GitHubRepoStatus |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 for using a concern here. Assignment and group-assignment are super similar, we should be using these more often.
lib/github/event.rb
Outdated
|
||
def latest_push_event(repo_id, options = { per_page: 100, page: 1 }) | ||
events = event_client.repository_events(repo_id, options).select do |event| | ||
event.type == 'PushEvent' || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These can be on the same line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👌
lib/github/event.rb
Outdated
(event.type == 'CreateEvent' && event.payload.ref.present?) | ||
end | ||
|
||
events.length.positive? ? events.first : nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason for this vs #empty
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch! Should have used #empty
for this.
I'm going to simplify this further using #first
only as the result will be the same according to the docs.
@@ -52,7 +52,9 @@ | |||
end | |||
|
|||
after(:build) do |organization, evaluator| | |||
create_list(:user, evaluator.users_count, organizations: [organization]) | |||
if evaluator.users.count < evaluator.users_count | |||
create_list(:user, evaluator.users_count, organizations: [organization]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, because a token is chosen from a random user. In that case, this makes sense to me.
This looks really good to me! Thanks for finishing this up |
Also I'd like to squash before we merge. You don't have to worry about it yet though. |
@nwoodthorpe Thanks for reviewing! I've updated the code to resolve the issues you spotted, please have a 👀 .
+1 on this. Would you like me to do that or this can be done using the squash on merge feature on GitHub? |
Code LGTM Yeah, squash on merge should be fine. @johndbritton for review |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Part of #613.
This pull request adds functionality for teachers to check the time of the last push and the build status of the latest commit.
Preview:
Edit: This feature is now placed under Flipper
teacher_dashboard
flag.Would love to hear you feedback! Thanks 😄