-
Notifications
You must be signed in to change notification settings - Fork 564
Create Membership Event Job #1254
Create Membership Event Job #1254
Conversation
e4750f9
to
0e5c2db
Compare
let(:organization) { classroom_org } | ||
let(:student) { create(:user, uid: payload.dig("member", "id")) } | ||
let(:repo_access) { RepoAccess.create(user: student, organization: organization) } | ||
let(:group) { Group.create(title: 'Group 2', github_team_id: payload.dig("team", "id")) } |
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.
Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
74923aa
to
d88effa
Compare
app/jobs/membership_event_job.rb
Outdated
team_id = payload_body.dig("team", "id") | ||
|
||
user = User.find_by(uid: user_id) | ||
return true if user.present? |
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 think the switches between if/unless and blank/present reversed the logic of this line (and the one for group below).
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.
But it still works though 🤔
group = Group.create(github_team_id: payload.dig("team", "id"), title: payload.dig("team", "name"), grouping: group_assignment.grouping) | ||
repo_access = RepoAccess.find_or_create_by!(user: student, organization: organization) | ||
|
||
#fails with the next 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.
Missing space after #.
context "ACTION member_removed", :vcr do | ||
it "removes user from team" do | ||
group_assignment = create(:group_assignment, title: "Intro to Rails #2", organization: organization) | ||
group = Group.create(github_team_id: payload.dig("team", "id"), title: payload.dig("team", "name"), grouping: group_assignment.grouping) |
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.
Line is too long. [142/120]
ff5a318
to
24b9faa
Compare
context "ACTION member_removed", :vcr do | ||
it "removes user from team" do | ||
group_assignment = create(:group_assignment, title: "Intro to Rails #2", organization: organization) | ||
group = Group.create(title: "GROUP", github_team_id: payload.dig("team", "id"), grouping: group_assignment.grouping) |
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.
Line is too long. [122/120]
@fjorgemota Not yet, just a little change and we will be good to change for review 👍 |
Guys, Sorry to bother again, but...is there any plans to review this? I'm going to use Github Classroom on a class this semester and this PR is very important to fix problems where a student join a wrong group. Thanks. |
Hey @fjorgemota , We're ramping up some more engineers to work on this project, but for now we don't have a ton of bandwidth. We'll get this shipped as soon as we can.
Are you saying there's a student who's joined the wrong group? Or you're trying to prevent that from happening in the future? If something's gone wrong with your Classroom, can you email |
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.
One super small style thing, this looks great! cc @tarebyte.
app/jobs/membership_event_job.rb
Outdated
queue_as :github_event | ||
|
||
def perform(payload_body) | ||
return true unless payload_body.dig("action") == "removed" |
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.
We probably don't need dig
here, we can just do payload_body["action"]
Hey @d12! Nice to know that Github Classroom will receive more attention! About your question, I'm trying to prevent that from happening on the class this semester, because for now the use of Github Classroom will be just a test with a class where i'm a teaching assistant, to see if it helps with the verification of the activities (just by having a simple About the test, I think that this is the most import important issue we detected right now that may affect us. We will use Github Classroom together with the Moodle of the university (not a direct integration, tho) so for us #603 will not be a big problem right now (because we will request the student to enter a limited group on Moodle (which have these restrictions) and on the same group on Github Classroom), so it's not a big problem right now. Anyway, here's a "how-to document" that me and the teacher developed to allow students to use git and github classroom more easily: https://github.com/nanvix/teaching/tree/master/howtos/github-classroom (it's in Portuguese, but ... okay) Thanks and keep the good work, guys. =D |
@fjorgemota Ah I see. We're done with reviewing now, so this will get deployed likely sometime today or tomorrow. :) Glad to hear you're trying out Classroom for your course, if you run into any problems or any features you think would help you, we take feature requests here! |
@d12 Nice! Thanks for the support, and like I said before, sorry for bothering. =) |
app/jobs/membership_event_job.rb
Outdated
return true unless group.present? && user.present? | ||
|
||
repo_access = group.repo_accesses.find_by(user_id: user.id) | ||
repo_access&.destroy |
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.
So I don't think we want to delete the repo_access here, just the fact has_and_belongs_to_many
relationship exists.
So it would be something like
repo_access = group.repo_accesses.find_by(user_id: user.id)
group.repo_accesses.delete(repo_access)
…com:education/classroom into synchronize_users_removed_from_organization
What happens now: When a member is removed from a team, Classroom still displays this member and do not let users join the team(because it appears to be full in some cases).
What it changes: Now we display the right numbers of members ✨
Why I need help: I think Travis is failing because when I run RSPEC locally and I create
RepoAccess
, it tries to add the user I created from the payload to my organization and apparently the API is not happy with that and returns a401
but for now I don't know why. I'm still trying to figure out why but if someone has an idea I'd be happy to hear more about it ✨To do next:
organization
👍