Skip to content
This repository has been archived by the owner on Jun 24, 2024. It is now read-only.

Create Membership Event Job #1254

Merged
merged 22 commits into from
Mar 13, 2018

Conversation

Kadaaran
Copy link
Contributor

@Kadaaran Kadaaran commented Feb 2, 2018

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 ✨

35402000-7faac1aa-01fb-11e8-804d-4606498a9e7a

35402001-7fe0fcc0-01fb-11e8-935c-ececee039496

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 a 401 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 ✨

screen shot 2018-02-02 at 23 06 37

To do next:

  • Same thing with people being removed from organization 👍
  • Fix this massive dependencies in the rspec file
  • Bug fixed thanks to @d12 🍰

@Kadaaran Kadaaran requested review from d12 and tarebyte February 2, 2018 17:22
@Kadaaran Kadaaran changed the title [WIP] Crete Membership Event Job [WIP] Create Membership Event Job Feb 2, 2018
@Kadaaran Kadaaran force-pushed the synchronize_users_removed_from_organization branch from e4750f9 to 0e5c2db Compare February 2, 2018 18:13
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")) }

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.

@Kadaaran Kadaaran changed the title [WIP] Create Membership Event Job Create Membership Event Job Feb 2, 2018
@Kadaaran Kadaaran added help wanted 🖐️ WIP 💭 PR's that are a 'Work In Progress' labels Feb 2, 2018
team_id = payload_body.dig("team", "id")

user = User.find_by(uid: user_id)
return true if user.present?

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).

Copy link
Contributor Author

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

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)

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]

@Kadaaran Kadaaran force-pushed the synchronize_users_removed_from_organization branch from ff5a318 to 24b9faa Compare February 23, 2018 17:25
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)

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]

@Kadaaran
Copy link
Contributor Author

Kadaaran commented Mar 5, 2018

@fjorgemota Not yet, just a little change and we will be good to change for review 👍

@Kadaaran Kadaaran added 🚀 ready for review and removed WIP 💭 PR's that are a 'Work In Progress' labels Mar 5, 2018
@fjorgemota
Copy link

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.

@d12
Copy link
Contributor

d12 commented Mar 12, 2018

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.

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.

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 education@github.com? We can try to get you sorted while you wait for this fix. Thanks :)

Copy link
Contributor

@d12 d12 left a 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.

queue_as :github_event

def perform(payload_body)
return true unless payload_body.dig("action") == "removed"
Copy link
Contributor

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"]

@fjorgemota
Copy link

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 git diff I think it will), and I did not know that you're available to receive small problems manually on the database (I mean, I think that this problem is not too frequent, but it's good to know anyway).

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

@d12
Copy link
Contributor

d12 commented Mar 12, 2018

@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!

@fjorgemota
Copy link

@d12 Nice! Thanks for the support, and like I said before, sorry for bothering. =)

return true unless group.present? && user.present?

repo_access = group.repo_accesses.find_by(user_id: user.id)
repo_access&.destroy
Copy link
Member

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)

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

Successfully merging this pull request may close these issues.

7 participants