{"action":"created","comment":{"url":"https://api.github.com/repos/alphasights/lion-api/pulls/comments/53552767","id":53552767,"diff_hunk":"@@ -0,0 +1,65 @@\n+class PointsMarshaller\n+  MATCHING_REGEX = /paired[\\s]*with[\\s]*(?<names>[@\\w+[\\s+|,]]+)/i\n+  SPLITTING_REGEX = /,|\\.|\\s+/\n+\n+  def initialize(data:)\n+    @data = data\n+  end\n+\n+  attr_accessor :data\n+\n+  def marshall\n+    pull_request = PullRequest.create(data)\n+    if pull_request.present? && pull_request.persisted?\n+      create_pairings(pull_request)\n+      create_reviews(pull_request)\n+    end\n+\n+    pull_request\n+  end\n+\n+  private\n+\n+  def create_reviews(pr)\n+    review_points = (pr.points / 2).round\n+    pr.comments.each do |comment|\n+      reviewer = User.where(nickname: comment.user.login).first\n+      pull_request_review = PullRequestReview.create(\n+        user: reviewer,\n+        body: comment.body,\n+        pull_request: pr\n+      )\n+      if pull_request_review.present? && pull_request_review.persisted?\n+        Score.give(time: pr.merged_at, user: reviewer, points: review_points)\n+      end\n+    end\n+  end\n+\n+  def create_pairings(pr)\n+    pair_points = (pr.points / pairers.size).round\n+    pairers.each do |u|\n+      pairing = Pairing.create(user: u, pull_request: pr)\n+      if pairing.present? && pairing.persisted?","path":"app/models/points_marshaller.rb","position":42,"original_position":42,"commit_id":"1bf8c2c23fcfe5ff975f334f0a133eeaa19e014b","original_commit_id":"1bf8c2c23fcfe5ff975f334f0a133eeaa19e014b","user":{"login":"abepetrillo","id":875501,"avatar_url":"https://avatars.githubusercontent.com/u/875501?v=3","gravatar_id":"","url":"https://api.github.com/users/abepetrillo","html_url":"https://github.com/abepetrillo","followers_url":"https://api.github.com/users/abepetrillo/followers","following_url":"https://api.github.com/users/abepetrillo/following{/other_user}","gists_url":"https://api.github.com/users/abepetrillo/gists{/gist_id}","starred_url":"https://api.github.com/users/abepetrillo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abepetrillo/subscriptions","organizations_url":"https://api.github.com/users/abepetrillo/orgs","repos_url":"https://api.github.com/users/abepetrillo/repos","events_url":"https://api.github.com/users/abepetrillo/events{/privacy}","received_events_url":"https://api.github.com/users/abepetrillo/received_events","type":"User","site_admin":false},"body":"and here","created_at":"2016-02-20T16:17:12Z","updated_at":"2016-02-20T16:17:12Z","html_url":"https://github.com/alphasights/lion-api/pull/46#discussion_r53552767","pull_request_url":"https://api.github.com/repos/alphasights/lion-api/pulls/46","_links":{"self":{"href":"https://api.github.com/repos/alphasights/lion-api/pulls/comments/53552767"},"html":{"href":"https://github.com/alphasights/lion-api/pull/46#discussion_r53552767"},"pull_request":{"href":"https://api.github.com/repos/alphasights/lion-api/pulls/46"}}},"pull_request":{"url":"https://api.github.com/repos/alphasights/lion-api/pulls/46","id":59956175,"html_url":"https://github.com/alphasights/lion-api/pull/46","diff_url":"https://github.com/alphasights/lion-api/pull/46.diff","patch_url":"https://github.com/alphasights/lion-api/pull/46.patch","issue_url":"https://api.github.com/repos/alphasights/lion-api/issues/46","number":46,"state":"open","locked":false,"title":"Enable shared points for pair programming","user":{"login":"delkopiso","id":5182637,"avatar_url":"https://avatars.githubusercontent.com/u/5182637?v=3","gravatar_id":"","url":"https://api.github.com/users/delkopiso","html_url":"https://github.com/delkopiso","followers_url":"https://api.github.com/users/delkopiso/followers","following_url":"https://api.github.com/users/delkopiso/following{/other_user}","gists_url":"https://api.github.com/users/delkopiso/gists{/gist_id}","starred_url":"https://api.github.com/users/delkopiso/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/delkopiso/subscriptions","organizations_url":"https://api.github.com/users/delkopiso/orgs","repos_url":"https://api.github.com/users/delkopiso/repos","events_url":"https://api.github.com/users/delkopiso/events{/privacy}","received_events_url":"https://api.github.com/users/delkopiso/received_events","type":"User","site_admin":false},"body":"# What's up\r\nWhen developers pair on a feature and one creates the pull request, only that developer gets all the points for the feature. In search of increased fairness in this regard there is a need to signal that a particular PR was the result of a combined effort by more than just the PR owner.\r\n\r\n# What this does\r\n- If a PR description has the phrase `paired with @abe` then the user with login `abe` gets to split the points on the PR with the creator.\r\n- Also works when multiple users are listed e.g. `Paired with @abe, @edjohn` or `I paired with @abe and @edjohn`.\r\n\r\n## Screenshots\r\n\r\n- Merged a PR that was worth 100 points.\r\n<img width=\"1037\" alt=\"screenshot 2016-02-20 11 00 57\" src=\"https://cloud.githubusercontent.com/assets/5182637/13197625/578fd77a-d7c1-11e5-8cbe-bd555242e326.png\">\r\n\r\n- Both the creator and the paired user received exactly 50 points.\r\n<img width=\"1277\" alt=\"screenshot 2016-02-20 11 01 13\" src=\"https://cloud.githubusercontent.com/assets/5182637/13197630/79968c56-d7c1-11e5-9d18-e8feb77dbfdd.png\">\r\n","created_at":"2016-02-19T14:30:56Z","updated_at":"2016-02-20T16:17:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c41e128426ddd0c77b94453747041c09507a6d72","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/alphasights/lion-api/pulls/46/commits","review_comments_url":"https://api.github.com/repos/alphasights/lion-api/pulls/46/comments","review_comment_url":"https://api.github.com/repos/alphasights/lion-api/pulls/comments{/number}","comments_url":"https://api.github.com/repos/alphasights/lion-api/issues/46/comments","statuses_url":"https://api.github.com/repos/alphasights/lion-api/statuses/1bf8c2c23fcfe5ff975f334f0a133eeaa19e014b","head":{"label":"alphasights:ku-paired-with","ref":"ku-paired-with","sha":"1bf8c2c23fcfe5ff975f334f0a133eeaa19e014b","user":{"login":"alphasights","id":41216,"avatar_url":"https://avatars.githubusercontent.com/u/41216?v=3","gravatar_id":"","url":"https://api.github.com/users/alphasights","html_url":"https://github.com/alphasights","followers_url":"https://api.github.com/users/alphasights/followers","following_url":"https://api.github.com/users/alphasights/following{/other_user}","gists_url":"https://api.github.com/users/alphasights/gists{/gist_id}","starred_url":"https://api.github.com/users/alphasights/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alphasights/subscriptions","organizations_url":"https://api.github.com/users/alphasights/orgs","repos_url":"https://api.github.com/users/alphasights/repos","events_url":"https://api.github.com/users/alphasights/events{/privacy}","received_events_url":"https://api.github.com/users/alphasights/received_events","type":"Organization","site_admin":false},"repo":{"id":18222734,"name":"lion-api","full_name":"alphasights/lion-api","owner":{"login":"alphasights","id":41216,"avatar_url":"https://avatars.githubusercontent.com/u/41216?v=3","gravatar_id":"","url":"https://api.github.com/users/alphasights","html_url":"https://github.com/alphasights","followers_url":"https://api.github.com/users/alphasights/followers","following_url":"https://api.github.com/users/alphasights/following{/other_user}","gists_url":"https://api.github.com/users/alphasights/gists{/gist_id}","starred_url":"https://api.github.com/users/alphasights/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alphasights/subscriptions","organizations_url":"https://api.github.com/users/alphasights/orgs","repos_url":"https://api.github.com/users/alphasights/repos","events_url":"https://api.github.com/users/alphasights/events{/privacy}","received_events_url":"https://api.github.com/users/alphasights/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/alphasights/lion-api","description":"Gamification for developers","fork":false,"url":"https://api.github.com/repos/alphasights/lion-api","forks_url":"https://api.github.com/repos/alphasights/lion-api/forks","keys_url":"https://api.github.com/repos/alphasights/lion-api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alphasights/lion-api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alphasights/lion-api/teams","hooks_url":"https://api.github.com/repos/alphasights/lion-api/hooks","issue_events_url":"https://api.github.com/repos/alphasights/lion-api/issues/events{/number}","events_url":"https://api.github.com/repos/alphasights/lion-api/events","assignees_url":"https://api.github.com/repos/alphasights/lion-api/assignees{/user}","branches_url":"https://api.github.com/repos/alphasights/lion-api/branches{/branch}","tags_url":"https://api.github.com/repos/alphasights/lion-api/tags","blobs_url":"https://api.github.com/repos/alphasights/lion-api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alphasights/lion-api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alphasights/lion-api/git/refs{/sha}","trees_url":"https://api.github.com/repos/alphasights/lion-api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alphasights/lion-api/statuses/{sha}","languages_url":"https://api.github.com/repos/alphasights/lion-api/languages","stargazers_url":"https://api.github.com/repos/alphasights/lion-api/stargazers","contributors_url":"https://api.github.com/repos/alphasights/lion-api/contributors","subscribers_url":"https://api.github.com/repos/alphasights/lion-api/subscribers","subscription_url":"https://api.github.com/repos/alphasights/lion-api/subscription","commits_url":"https://api.github.com/repos/alphasights/lion-api/commits{/sha}","git_commits_url":"https://api.github.com/repos/alphasights/lion-api/git/commits{/sha}","comments_url":"https://api.github.com/repos/alphasights/lion-api/comments{/number}","issue_comment_url":"https://api.github.com/repos/alphasights/lion-api/issues/comments{/number}","contents_url":"https://api.github.com/repos/alphasights/lion-api/contents/{+path}","compare_url":"https://api.github.com/repos/alphasights/lion-api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alphasights/lion-api/merges","archive_url":"https://api.github.com/repos/alphasights/lion-api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alphasights/lion-api/downloads","issues_url":"https://api.github.com/repos/alphasights/lion-api/issues{/number}","pulls_url":"https://api.github.com/repos/alphasights/lion-api/pulls{/number}","milestones_url":"https://api.github.com/repos/alphasights/lion-api/milestones{/number}","notifications_url":"https://api.github.com/repos/alphasights/lion-api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alphasights/lion-api/labels{/name}","releases_url":"https://api.github.com/repos/alphasights/lion-api/releases{/id}","deployments_url":"https://api.github.com/repos/alphasights/lion-api/deployments","created_at":"2014-03-28T18:45:07Z","updated_at":"2016-01-25T19:57:57Z","pushed_at":"2016-02-20T14:25:25Z","git_url":"git://github.com/alphasights/lion-api.git","ssh_url":"git@github.com:alphasights/lion-api.git","clone_url":"https://github.com/alphasights/lion-api.git","svn_url":"https://github.com/alphasights/lion-api","homepage":"","size":1564,"stargazers_count":5,"watchers_count":5,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":5,"default_branch":"master"}},"base":{"label":"alphasights:master","ref":"master","sha":"3dfc3f256c8072436e6845bae50fddb2895ebd04","user":{"login":"alphasights","id":41216,"avatar_url":"https://avatars.githubusercontent.com/u/41216?v=3","gravatar_id":"","url":"https://api.github.com/users/alphasights","html_url":"https://github.com/alphasights","followers_url":"https://api.github.com/users/alphasights/followers","following_url":"https://api.github.com/users/alphasights/following{/other_user}","gists_url":"https://api.github.com/users/alphasights/gists{/gist_id}","starred_url":"https://api.github.com/users/alphasights/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alphasights/subscriptions","organizations_url":"https://api.github.com/users/alphasights/orgs","repos_url":"https://api.github.com/users/alphasights/repos","events_url":"https://api.github.com/users/alphasights/events{/privacy}","received_events_url":"https://api.github.com/users/alphasights/received_events","type":"Organization","site_admin":false},"repo":{"id":18222734,"name":"lion-api","full_name":"alphasights/lion-api","owner":{"login":"alphasights","id":41216,"avatar_url":"https://avatars.githubusercontent.com/u/41216?v=3","gravatar_id":"","url":"https://api.github.com/users/alphasights","html_url":"https://github.com/alphasights","followers_url":"https://api.github.com/users/alphasights/followers","following_url":"https://api.github.com/users/alphasights/following{/other_user}","gists_url":"https://api.github.com/users/alphasights/gists{/gist_id}","starred_url":"https://api.github.com/users/alphasights/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alphasights/subscriptions","organizations_url":"https://api.github.com/users/alphasights/orgs","repos_url":"https://api.github.com/users/alphasights/repos","events_url":"https://api.github.com/users/alphasights/events{/privacy}","received_events_url":"https://api.github.com/users/alphasights/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/alphasights/lion-api","description":"Gamification for developers","fork":false,"url":"https://api.github.com/repos/alphasights/lion-api","forks_url":"https://api.github.com/repos/alphasights/lion-api/forks","keys_url":"https://api.github.com/repos/alphasights/lion-api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alphasights/lion-api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alphasights/lion-api/teams","hooks_url":"https://api.github.com/repos/alphasights/lion-api/hooks","issue_events_url":"https://api.github.com/repos/alphasights/lion-api/issues/events{/number}","events_url":"https://api.github.com/repos/alphasights/lion-api/events","assignees_url":"https://api.github.com/repos/alphasights/lion-api/assignees{/user}","branches_url":"https://api.github.com/repos/alphasights/lion-api/branches{/branch}","tags_url":"https://api.github.com/repos/alphasights/lion-api/tags","blobs_url":"https://api.github.com/repos/alphasights/lion-api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alphasights/lion-api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alphasights/lion-api/git/refs{/sha}","trees_url":"https://api.github.com/repos/alphasights/lion-api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alphasights/lion-api/statuses/{sha}","languages_url":"https://api.github.com/repos/alphasights/lion-api/languages","stargazers_url":"https://api.github.com/repos/alphasights/lion-api/stargazers","contributors_url":"https://api.github.com/repos/alphasights/lion-api/contributors","subscribers_url":"https://api.github.com/repos/alphasights/lion-api/subscribers","subscription_url":"https://api.github.com/repos/alphasights/lion-api/subscription","commits_url":"https://api.github.com/repos/alphasights/lion-api/commits{/sha}","git_commits_url":"https://api.github.com/repos/alphasights/lion-api/git/commits{/sha}","comments_url":"https://api.github.com/repos/alphasights/lion-api/comments{/number}","issue_comment_url":"https://api.github.com/repos/alphasights/lion-api/issues/comments{/number}","contents_url":"https://api.github.com/repos/alphasights/lion-api/contents/{+path}","compare_url":"https://api.github.com/repos/alphasights/lion-api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alphasights/lion-api/merges","archive_url":"https://api.github.com/repos/alphasights/lion-api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alphasights/lion-api/downloads","issues_url":"https://api.github.com/repos/alphasights/lion-api/issues{/number}","pulls_url":"https://api.github.com/repos/alphasights/lion-api/pulls{/number}","milestones_url":"https://api.github.com/repos/alphasights/lion-api/milestones{/number}","notifications_url":"https://api.github.com/repos/alphasights/lion-api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alphasights/lion-api/labels{/name}","releases_url":"https://api.github.com/repos/alphasights/lion-api/releases{/id}","deployments_url":"https://api.github.com/repos/alphasights/lion-api/deployments","created_at":"2014-03-28T18:45:07Z","updated_at":"2016-01-25T19:57:57Z","pushed_at":"2016-02-20T14:25:25Z","git_url":"git://github.com/alphasights/lion-api.git","ssh_url":"git@github.com:alphasights/lion-api.git","clone_url":"https://github.com/alphasights/lion-api.git","svn_url":"https://github.com/alphasights/lion-api","homepage":"","size":1564,"stargazers_count":5,"watchers_count":5,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":5,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/alphasights/lion-api/pulls/46"},"html":{"href":"https://github.com/alphasights/lion-api/pull/46"},"issue":{"href":"https://api.github.com/repos/alphasights/lion-api/issues/46"},"comments":{"href":"https://api.github.com/repos/alphasights/lion-api/issues/46/comments"},"review_comments":{"href":"https://api.github.com/repos/alphasights/lion-api/pulls/46/comments"},"review_comment":{"href":"https://api.github.com/repos/alphasights/lion-api/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/alphasights/lion-api/pulls/46/commits"},"statuses":{"href":"https://api.github.com/repos/alphasights/lion-api/statuses/1bf8c2c23fcfe5ff975f334f0a133eeaa19e014b"}}}}