{"action":"created","comment":{"url":"https://api.github.com/repos/openstax/tutor-server/pulls/comments/35207702","id":35207702,"diff_hunk":"@@ -16,7 +19,7 @@ class CourseMembership::Models::Period < Tutor::SubSystems::BaseModel\n   default_scope { order(:name) }\n \n   def student_roles\n-    enrollments.latest.active.includes(student: :role).collect{ |en| en.student.role }\n+    active_enrollments.includes(student: :role).collect{ |en| en.student.role }","path":"app/subsystems/course_membership/models/period.rb","position":15,"original_position":15,"commit_id":"c1f4d5afc271278edf6ad58bbe307391aa5a9546","original_commit_id":"c8b8ce021d7d6ade0f27301510d88f84fce3e410","user":{"login":"karenc","id":153353,"avatar_url":"https://avatars.githubusercontent.com/u/153353?v=3","gravatar_id":"","url":"https://api.github.com/users/karenc","html_url":"https://github.com/karenc","followers_url":"https://api.github.com/users/karenc/followers","following_url":"https://api.github.com/users/karenc/following{/other_user}","gists_url":"https://api.github.com/users/karenc/gists{/gist_id}","starred_url":"https://api.github.com/users/karenc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/karenc/subscriptions","organizations_url":"https://api.github.com/users/karenc/orgs","repos_url":"https://api.github.com/users/karenc/repos","events_url":"https://api.github.com/users/karenc/events{/privacy}","received_events_url":"https://api.github.com/users/karenc/received_events","type":"User","site_admin":false},"body":"I think `has_many` with lambda has an optional argument which is the object itself (a `CourseMembership::Models::Period` instance) if I understand it correctly.\r\n\r\nFor example:\r\n`CourseMembership::Models::Period.first.student_roles`, the `active_enrollments` `period` argument is `CourseMembership::Models::Period.first`.\r\n\r\nDon't know if this answers your question.","created_at":"2015-07-22T12:40:15Z","updated_at":"2015-07-22T12:40:15Z","html_url":"https://github.com/openstax/tutor-server/pull/501#discussion_r35207702","pull_request_url":"https://api.github.com/repos/openstax/tutor-server/pulls/501","_links":{"self":{"href":"https://api.github.com/repos/openstax/tutor-server/pulls/comments/35207702"},"html":{"href":"https://github.com/openstax/tutor-server/pull/501#discussion_r35207702"},"pull_request":{"href":"https://api.github.com/repos/openstax/tutor-server/pulls/501"}}},"pull_request":{"url":"https://api.github.com/repos/openstax/tutor-server/pulls/501","id":40510550,"html_url":"https://github.com/openstax/tutor-server/pull/501","diff_url":"https://github.com/openstax/tutor-server/pull/501.diff","patch_url":"https://github.com/openstax/tutor-server/pull/501.patch","issue_url":"https://api.github.com/repos/openstax/tutor-server/issues/501","number":501,"state":"open","locked":false,"title":"Add first and last names to performance report","user":{"login":"karenc","id":153353,"avatar_url":"https://avatars.githubusercontent.com/u/153353?v=3","gravatar_id":"","url":"https://api.github.com/users/karenc","html_url":"https://github.com/karenc","followers_url":"https://api.github.com/users/karenc/followers","following_url":"https://api.github.com/users/karenc/following{/other_user}","gists_url":"https://api.github.com/users/karenc/gists{/gist_id}","starred_url":"https://api.github.com/users/karenc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/karenc/subscriptions","organizations_url":"https://api.github.com/users/karenc/orgs","repos_url":"https://api.github.com/users/karenc/repos","events_url":"https://api.github.com/users/karenc/events{/privacy}","received_events_url":"https://api.github.com/users/karenc/received_events","type":"User","site_admin":false},"body":"- Simplify GetStudentProfiles and remove CourseMembership::GetStudents\r\n- Add first and last names to performance report\r\n- Add first and last names to performance report exports\r\n- Remove extra delegate in CourseMembership::Models::Student","created_at":"2015-07-21T22:07:40Z","updated_at":"2015-07-22T12:40:16Z","closed_at":null,"merged_at":null,"merge_commit_sha":"597ecd6040c0e402a6a2be7cf1ec87a26516f478","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/openstax/tutor-server/pulls/501/commits","review_comments_url":"https://api.github.com/repos/openstax/tutor-server/pulls/501/comments","review_comment_url":"https://api.github.com/repos/openstax/tutor-server/pulls/comments{/number}","comments_url":"https://api.github.com/repos/openstax/tutor-server/issues/501/comments","statuses_url":"https://api.github.com/repos/openstax/tutor-server/statuses/c1f4d5afc271278edf6ad58bbe307391aa5a9546","head":{"label":"openstax:add-first-last-names","ref":"add-first-last-names","sha":"c1f4d5afc271278edf6ad58bbe307391aa5a9546","user":{"login":"openstax","id":3805549,"avatar_url":"https://avatars.githubusercontent.com/u/3805549?v=3","gravatar_id":"","url":"https://api.github.com/users/openstax","html_url":"https://github.com/openstax","followers_url":"https://api.github.com/users/openstax/followers","following_url":"https://api.github.com/users/openstax/following{/other_user}","gists_url":"https://api.github.com/users/openstax/gists{/gist_id}","starred_url":"https://api.github.com/users/openstax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openstax/subscriptions","organizations_url":"https://api.github.com/users/openstax/orgs","repos_url":"https://api.github.com/users/openstax/repos","events_url":"https://api.github.com/users/openstax/events{/privacy}","received_events_url":"https://api.github.com/users/openstax/received_events","type":"Organization","site_admin":false},"repo":{"id":24337612,"name":"tutor-server","full_name":"openstax/tutor-server","owner":{"login":"openstax","id":3805549,"avatar_url":"https://avatars.githubusercontent.com/u/3805549?v=3","gravatar_id":"","url":"https://api.github.com/users/openstax","html_url":"https://github.com/openstax","followers_url":"https://api.github.com/users/openstax/followers","following_url":"https://api.github.com/users/openstax/following{/other_user}","gists_url":"https://api.github.com/users/openstax/gists{/gist_id}","starred_url":"https://api.github.com/users/openstax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openstax/subscriptions","organizations_url":"https://api.github.com/users/openstax/orgs","repos_url":"https://api.github.com/users/openstax/repos","events_url":"https://api.github.com/users/openstax/events{/privacy}","received_events_url":"https://api.github.com/users/openstax/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/openstax/tutor-server","description":":mortar_board: OpenStax Tutor 3.0 Backend","fork":false,"url":"https://api.github.com/repos/openstax/tutor-server","forks_url":"https://api.github.com/repos/openstax/tutor-server/forks","keys_url":"https://api.github.com/repos/openstax/tutor-server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/openstax/tutor-server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/openstax/tutor-server/teams","hooks_url":"https://api.github.com/repos/openstax/tutor-server/hooks","issue_events_url":"https://api.github.com/repos/openstax/tutor-server/issues/events{/number}","events_url":"https://api.github.com/repos/openstax/tutor-server/events","assignees_url":"https://api.github.com/repos/openstax/tutor-server/assignees{/user}","branches_url":"https://api.github.com/repos/openstax/tutor-server/branches{/branch}","tags_url":"https://api.github.com/repos/openstax/tutor-server/tags","blobs_url":"https://api.github.com/repos/openstax/tutor-server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/openstax/tutor-server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/openstax/tutor-server/git/refs{/sha}","trees_url":"https://api.github.com/repos/openstax/tutor-server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/openstax/tutor-server/statuses/{sha}","languages_url":"https://api.github.com/repos/openstax/tutor-server/languages","stargazers_url":"https://api.github.com/repos/openstax/tutor-server/stargazers","contributors_url":"https://api.github.com/repos/openstax/tutor-server/contributors","subscribers_url":"https://api.github.com/repos/openstax/tutor-server/subscribers","subscription_url":"https://api.github.com/repos/openstax/tutor-server/subscription","commits_url":"https://api.github.com/repos/openstax/tutor-server/commits{/sha}","git_commits_url":"https://api.github.com/repos/openstax/tutor-server/git/commits{/sha}","comments_url":"https://api.github.com/repos/openstax/tutor-server/comments{/number}","issue_comment_url":"https://api.github.com/repos/openstax/tutor-server/issues/comments{/number}","contents_url":"https://api.github.com/repos/openstax/tutor-server/contents/{+path}","compare_url":"https://api.github.com/repos/openstax/tutor-server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/openstax/tutor-server/merges","archive_url":"https://api.github.com/repos/openstax/tutor-server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/openstax/tutor-server/downloads","issues_url":"https://api.github.com/repos/openstax/tutor-server/issues{/number}","pulls_url":"https://api.github.com/repos/openstax/tutor-server/pulls{/number}","milestones_url":"https://api.github.com/repos/openstax/tutor-server/milestones{/number}","notifications_url":"https://api.github.com/repos/openstax/tutor-server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/openstax/tutor-server/labels{/name}","releases_url":"https://api.github.com/repos/openstax/tutor-server/releases{/id}","created_at":"2014-09-22T17:10:29Z","updated_at":"2015-06-29T16:30:39Z","pushed_at":"2015-07-22T12:25:35Z","git_url":"git://github.com/openstax/tutor-server.git","ssh_url":"git@github.com:openstax/tutor-server.git","clone_url":"https://github.com/openstax/tutor-server.git","svn_url":"https://github.com/openstax/tutor-server","homepage":"","size":23506,"stargazers_count":2,"watchers_count":2,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":37,"forks":4,"open_issues":37,"watchers":2,"default_branch":"master"}},"base":{"label":"openstax:master","ref":"master","sha":"610769327c7b130e83620d3d821184002d2fdf89","user":{"login":"openstax","id":3805549,"avatar_url":"https://avatars.githubusercontent.com/u/3805549?v=3","gravatar_id":"","url":"https://api.github.com/users/openstax","html_url":"https://github.com/openstax","followers_url":"https://api.github.com/users/openstax/followers","following_url":"https://api.github.com/users/openstax/following{/other_user}","gists_url":"https://api.github.com/users/openstax/gists{/gist_id}","starred_url":"https://api.github.com/users/openstax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openstax/subscriptions","organizations_url":"https://api.github.com/users/openstax/orgs","repos_url":"https://api.github.com/users/openstax/repos","events_url":"https://api.github.com/users/openstax/events{/privacy}","received_events_url":"https://api.github.com/users/openstax/received_events","type":"Organization","site_admin":false},"repo":{"id":24337612,"name":"tutor-server","full_name":"openstax/tutor-server","owner":{"login":"openstax","id":3805549,"avatar_url":"https://avatars.githubusercontent.com/u/3805549?v=3","gravatar_id":"","url":"https://api.github.com/users/openstax","html_url":"https://github.com/openstax","followers_url":"https://api.github.com/users/openstax/followers","following_url":"https://api.github.com/users/openstax/following{/other_user}","gists_url":"https://api.github.com/users/openstax/gists{/gist_id}","starred_url":"https://api.github.com/users/openstax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openstax/subscriptions","organizations_url":"https://api.github.com/users/openstax/orgs","repos_url":"https://api.github.com/users/openstax/repos","events_url":"https://api.github.com/users/openstax/events{/privacy}","received_events_url":"https://api.github.com/users/openstax/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/openstax/tutor-server","description":":mortar_board: OpenStax Tutor 3.0 Backend","fork":false,"url":"https://api.github.com/repos/openstax/tutor-server","forks_url":"https://api.github.com/repos/openstax/tutor-server/forks","keys_url":"https://api.github.com/repos/openstax/tutor-server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/openstax/tutor-server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/openstax/tutor-server/teams","hooks_url":"https://api.github.com/repos/openstax/tutor-server/hooks","issue_events_url":"https://api.github.com/repos/openstax/tutor-server/issues/events{/number}","events_url":"https://api.github.com/repos/openstax/tutor-server/events","assignees_url":"https://api.github.com/repos/openstax/tutor-server/assignees{/user}","branches_url":"https://api.github.com/repos/openstax/tutor-server/branches{/branch}","tags_url":"https://api.github.com/repos/openstax/tutor-server/tags","blobs_url":"https://api.github.com/repos/openstax/tutor-server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/openstax/tutor-server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/openstax/tutor-server/git/refs{/sha}","trees_url":"https://api.github.com/repos/openstax/tutor-server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/openstax/tutor-server/statuses/{sha}","languages_url":"https://api.github.com/repos/openstax/tutor-server/languages","stargazers_url":"https://api.github.com/repos/openstax/tutor-server/stargazers","contributors_url":"https://api.github.com/repos/openstax/tutor-server/contributors","subscribers_url":"https://api.github.com/repos/openstax/tutor-server/subscribers","subscription_url":"https://api.github.com/repos/openstax/tutor-server/subscription","commits_url":"https://api.github.com/repos/openstax/tutor-server/commits{/sha}","git_commits_url":"https://api.github.com/repos/openstax/tutor-server/git/commits{/sha}","comments_url":"https://api.github.com/repos/openstax/tutor-server/comments{/number}","issue_comment_url":"https://api.github.com/repos/openstax/tutor-server/issues/comments{/number}","contents_url":"https://api.github.com/repos/openstax/tutor-server/contents/{+path}","compare_url":"https://api.github.com/repos/openstax/tutor-server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/openstax/tutor-server/merges","archive_url":"https://api.github.com/repos/openstax/tutor-server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/openstax/tutor-server/downloads","issues_url":"https://api.github.com/repos/openstax/tutor-server/issues{/number}","pulls_url":"https://api.github.com/repos/openstax/tutor-server/pulls{/number}","milestones_url":"https://api.github.com/repos/openstax/tutor-server/milestones{/number}","notifications_url":"https://api.github.com/repos/openstax/tutor-server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/openstax/tutor-server/labels{/name}","releases_url":"https://api.github.com/repos/openstax/tutor-server/releases{/id}","created_at":"2014-09-22T17:10:29Z","updated_at":"2015-06-29T16:30:39Z","pushed_at":"2015-07-22T12:25:35Z","git_url":"git://github.com/openstax/tutor-server.git","ssh_url":"git@github.com:openstax/tutor-server.git","clone_url":"https://github.com/openstax/tutor-server.git","svn_url":"https://github.com/openstax/tutor-server","homepage":"","size":23506,"stargazers_count":2,"watchers_count":2,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":37,"forks":4,"open_issues":37,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/openstax/tutor-server/pulls/501"},"html":{"href":"https://github.com/openstax/tutor-server/pull/501"},"issue":{"href":"https://api.github.com/repos/openstax/tutor-server/issues/501"},"comments":{"href":"https://api.github.com/repos/openstax/tutor-server/issues/501/comments"},"review_comments":{"href":"https://api.github.com/repos/openstax/tutor-server/pulls/501/comments"},"review_comment":{"href":"https://api.github.com/repos/openstax/tutor-server/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/openstax/tutor-server/pulls/501/commits"},"statuses":{"href":"https://api.github.com/repos/openstax/tutor-server/statuses/c1f4d5afc271278edf6ad58bbe307391aa5a9546"}}}}