{"action":"created","comment":{"url":"https://api.github.com/repos/Yinaura/jagi/pulls/comments/37717303","id":37717303,"diff_hunk":"@@ -1,12 +1,61 @@\n class UserProfile < ActiveRecord::Base\n   belongs_to :user\n   has_many :profile_images\n+  belongs_to :project\n+  belongs_to :group\n+\n   delegate :name, to: :user\n+\n   validates :user_id, presence: true, numericality: true, uniqueness: true\n-  validates :answer_name, length: { maximum: 30 }\n+  validates :answer_name, allow_nil: true, length: { maximum: 30 }\n+  validates :group_id, allow_nil: true, numericality: true\n+  validates :project_id, allow_nil: true, numericality: true\n+  validates :gender, allow_nil: true, inclusion: { in: ['', 'male', 'female'] }\n+  validates :joined_year, allow_nil: true, numericality: true\n+  validates :detail, allow_nil: true, length: { maximum: 10000 }\n+\n+  def self.joined_years\n+    joined_years = []\n+    for year in 1990..Time.now.year+1 do\n+      joined_years.unshift [\"#{year}#{I18n.t('user_profiles.edit.year')}\", year]\n+    end\n+    joined_years\n+  end\n+\n+  def self.for_filter_params\n+    [:joined_year, :group_id, :project_id]\n+  end\n+\n+  def answer_user(filter = {}, user_profile = {})\n+    conditions = self.class.arel_table[:answer_name].not_eq(nil)\n+\n+    review_mode_condition = self.review_mode_condition(conditions, user_profile) if filter['review_mode'].present? && user_profile.present?\n+      if review_mode_condition\n+        conditions = conditions.and(review_mode_condition)\n+      end\n+\n+    conditions = conditions.and(self.class.arel_table[:project_id].eq(filter['project_id'])) if filter['project_id'].present?","path":"app/models/user_profile.rb","position":null,"original_position":38,"commit_id":"3e4fd4276820224a9b94ae173937e542ce40b324","original_commit_id":"4bc6eeb479d2d8c08830485fd74727e0c1e4f36f","user":{"login":"Yinaura","id":13635059,"avatar_url":"https://avatars.githubusercontent.com/u/13635059?v=3","gravatar_id":"","url":"https://api.github.com/users/Yinaura","html_url":"https://github.com/Yinaura","followers_url":"https://api.github.com/users/Yinaura/followers","following_url":"https://api.github.com/users/Yinaura/following{/other_user}","gists_url":"https://api.github.com/users/Yinaura/gists{/gist_id}","starred_url":"https://api.github.com/users/Yinaura/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Yinaura/subscriptions","organizations_url":"https://api.github.com/users/Yinaura/orgs","repos_url":"https://api.github.com/users/Yinaura/repos","events_url":"https://api.github.com/users/Yinaura/events{/privacy}","received_events_url":"https://api.github.com/users/Yinaura/received_events","type":"User","site_admin":false},"body":"#18 で、普通のwhereを使って書くように変更しました :)","created_at":"2015-08-24T03:32:22Z","updated_at":"2015-08-24T03:32:22Z","html_url":"https://github.com/Yinaura/jagi/pull/17#discussion_r37717303","pull_request_url":"https://api.github.com/repos/Yinaura/jagi/pulls/17","_links":{"self":{"href":"https://api.github.com/repos/Yinaura/jagi/pulls/comments/37717303"},"html":{"href":"https://github.com/Yinaura/jagi/pull/17#discussion_r37717303"},"pull_request":{"href":"https://api.github.com/repos/Yinaura/jagi/pulls/17"}}},"pull_request":{"url":"https://api.github.com/repos/Yinaura/jagi/pulls/17","id":42683911,"html_url":"https://github.com/Yinaura/jagi/pull/17","diff_url":"https://github.com/Yinaura/jagi/pull/17.diff","patch_url":"https://github.com/Yinaura/jagi/pull/17.patch","issue_url":"https://api.github.com/repos/Yinaura/jagi/issues/17","number":17,"state":"open","locked":false,"title":"プロフィールに所属プロジェクト/グループなどを登録できるようにする","user":{"login":"Yinaura","id":13635059,"avatar_url":"https://avatars.githubusercontent.com/u/13635059?v=3","gravatar_id":"","url":"https://api.github.com/users/Yinaura","html_url":"https://github.com/Yinaura","followers_url":"https://api.github.com/users/Yinaura/followers","following_url":"https://api.github.com/users/Yinaura/following{/other_user}","gists_url":"https://api.github.com/users/Yinaura/gists{/gist_id}","starred_url":"https://api.github.com/users/Yinaura/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Yinaura/subscriptions","organizations_url":"https://api.github.com/users/Yinaura/orgs","repos_url":"https://api.github.com/users/Yinaura/repos","events_url":"https://api.github.com/users/Yinaura/events{/privacy}","received_events_url":"https://api.github.com/users/Yinaura/received_events","type":"User","site_admin":false},"body":"# ご注意\r\n\r\n複数の更新が混ざっていたため、プルリクを #18 と分けました。レビューへの対応は #18 でおこなっているものがあります。\r\n\r\n# 内容\r\n\r\n- 登録できるようにした項目\r\n - 所属プロジェクト\r\n - 所属グループ \r\n - 性別\r\n - 入社年度\r\n - 自由入力欄\r\n\r\n# 前提条件\r\n\r\n- 所属グループ groups / 所属プロジェクト projects の内容は、運用上、SQLを直接発行して、手動でデータを作成します。\r\n","created_at":"2015-08-18T10:38:27Z","updated_at":"2015-08-24T03:32:22Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bd73c79af14567b5d7f4d8bf1112f560b18a6364","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Yinaura/jagi/pulls/17/commits","review_comments_url":"https://api.github.com/repos/Yinaura/jagi/pulls/17/comments","review_comment_url":"https://api.github.com/repos/Yinaura/jagi/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Yinaura/jagi/issues/17/comments","statuses_url":"https://api.github.com/repos/Yinaura/jagi/statuses/3e4fd4276820224a9b94ae173937e542ce40b324","head":{"label":"Yinaura:add-register-profile","ref":"add-register-profile","sha":"3e4fd4276820224a9b94ae173937e542ce40b324","user":{"login":"Yinaura","id":13635059,"avatar_url":"https://avatars.githubusercontent.com/u/13635059?v=3","gravatar_id":"","url":"https://api.github.com/users/Yinaura","html_url":"https://github.com/Yinaura","followers_url":"https://api.github.com/users/Yinaura/followers","following_url":"https://api.github.com/users/Yinaura/following{/other_user}","gists_url":"https://api.github.com/users/Yinaura/gists{/gist_id}","starred_url":"https://api.github.com/users/Yinaura/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Yinaura/subscriptions","organizations_url":"https://api.github.com/users/Yinaura/orgs","repos_url":"https://api.github.com/users/Yinaura/repos","events_url":"https://api.github.com/users/Yinaura/events{/privacy}","received_events_url":"https://api.github.com/users/Yinaura/received_events","type":"User","site_admin":false},"repo":{"id":40160096,"name":"jagi","full_name":"Yinaura/jagi","owner":{"login":"Yinaura","id":13635059,"avatar_url":"https://avatars.githubusercontent.com/u/13635059?v=3","gravatar_id":"","url":"https://api.github.com/users/Yinaura","html_url":"https://github.com/Yinaura","followers_url":"https://api.github.com/users/Yinaura/followers","following_url":"https://api.github.com/users/Yinaura/following{/other_user}","gists_url":"https://api.github.com/users/Yinaura/gists{/gist_id}","starred_url":"https://api.github.com/users/Yinaura/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Yinaura/subscriptions","organizations_url":"https://api.github.com/users/Yinaura/orgs","repos_url":"https://api.github.com/users/Yinaura/repos","events_url":"https://api.github.com/users/Yinaura/events{/privacy}","received_events_url":"https://api.github.com/users/Yinaura/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Yinaura/jagi","description":"","fork":false,"url":"https://api.github.com/repos/Yinaura/jagi","forks_url":"https://api.github.com/repos/Yinaura/jagi/forks","keys_url":"https://api.github.com/repos/Yinaura/jagi/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Yinaura/jagi/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Yinaura/jagi/teams","hooks_url":"https://api.github.com/repos/Yinaura/jagi/hooks","issue_events_url":"https://api.github.com/repos/Yinaura/jagi/issues/events{/number}","events_url":"https://api.github.com/repos/Yinaura/jagi/events","assignees_url":"https://api.github.com/repos/Yinaura/jagi/assignees{/user}","branches_url":"https://api.github.com/repos/Yinaura/jagi/branches{/branch}","tags_url":"https://api.github.com/repos/Yinaura/jagi/tags","blobs_url":"https://api.github.com/repos/Yinaura/jagi/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Yinaura/jagi/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Yinaura/jagi/git/refs{/sha}","trees_url":"https://api.github.com/repos/Yinaura/jagi/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Yinaura/jagi/statuses/{sha}","languages_url":"https://api.github.com/repos/Yinaura/jagi/languages","stargazers_url":"https://api.github.com/repos/Yinaura/jagi/stargazers","contributors_url":"https://api.github.com/repos/Yinaura/jagi/contributors","subscribers_url":"https://api.github.com/repos/Yinaura/jagi/subscribers","subscription_url":"https://api.github.com/repos/Yinaura/jagi/subscription","commits_url":"https://api.github.com/repos/Yinaura/jagi/commits{/sha}","git_commits_url":"https://api.github.com/repos/Yinaura/jagi/git/commits{/sha}","comments_url":"https://api.github.com/repos/Yinaura/jagi/comments{/number}","issue_comment_url":"https://api.github.com/repos/Yinaura/jagi/issues/comments{/number}","contents_url":"https://api.github.com/repos/Yinaura/jagi/contents/{+path}","compare_url":"https://api.github.com/repos/Yinaura/jagi/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Yinaura/jagi/merges","archive_url":"https://api.github.com/repos/Yinaura/jagi/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Yinaura/jagi/downloads","issues_url":"https://api.github.com/repos/Yinaura/jagi/issues{/number}","pulls_url":"https://api.github.com/repos/Yinaura/jagi/pulls{/number}","milestones_url":"https://api.github.com/repos/Yinaura/jagi/milestones{/number}","notifications_url":"https://api.github.com/repos/Yinaura/jagi/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Yinaura/jagi/labels{/name}","releases_url":"https://api.github.com/repos/Yinaura/jagi/releases{/id}","created_at":"2015-08-04T02:57:51Z","updated_at":"2015-08-04T03:10:49Z","pushed_at":"2015-08-24T03:31:21Z","git_url":"git://github.com/Yinaura/jagi.git","ssh_url":"git@github.com:Yinaura/jagi.git","clone_url":"https://github.com/Yinaura/jagi.git","svn_url":"https://github.com/Yinaura/jagi","homepage":null,"size":1444,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":6,"forks":1,"open_issues":6,"watchers":0,"default_branch":"master"}},"base":{"label":"Yinaura:master","ref":"master","sha":"21e76342677b94556d39ddded771a73013addce9","user":{"login":"Yinaura","id":13635059,"avatar_url":"https://avatars.githubusercontent.com/u/13635059?v=3","gravatar_id":"","url":"https://api.github.com/users/Yinaura","html_url":"https://github.com/Yinaura","followers_url":"https://api.github.com/users/Yinaura/followers","following_url":"https://api.github.com/users/Yinaura/following{/other_user}","gists_url":"https://api.github.com/users/Yinaura/gists{/gist_id}","starred_url":"https://api.github.com/users/Yinaura/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Yinaura/subscriptions","organizations_url":"https://api.github.com/users/Yinaura/orgs","repos_url":"https://api.github.com/users/Yinaura/repos","events_url":"https://api.github.com/users/Yinaura/events{/privacy}","received_events_url":"https://api.github.com/users/Yinaura/received_events","type":"User","site_admin":false},"repo":{"id":40160096,"name":"jagi","full_name":"Yinaura/jagi","owner":{"login":"Yinaura","id":13635059,"avatar_url":"https://avatars.githubusercontent.com/u/13635059?v=3","gravatar_id":"","url":"https://api.github.com/users/Yinaura","html_url":"https://github.com/Yinaura","followers_url":"https://api.github.com/users/Yinaura/followers","following_url":"https://api.github.com/users/Yinaura/following{/other_user}","gists_url":"https://api.github.com/users/Yinaura/gists{/gist_id}","starred_url":"https://api.github.com/users/Yinaura/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Yinaura/subscriptions","organizations_url":"https://api.github.com/users/Yinaura/orgs","repos_url":"https://api.github.com/users/Yinaura/repos","events_url":"https://api.github.com/users/Yinaura/events{/privacy}","received_events_url":"https://api.github.com/users/Yinaura/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Yinaura/jagi","description":"","fork":false,"url":"https://api.github.com/repos/Yinaura/jagi","forks_url":"https://api.github.com/repos/Yinaura/jagi/forks","keys_url":"https://api.github.com/repos/Yinaura/jagi/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Yinaura/jagi/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Yinaura/jagi/teams","hooks_url":"https://api.github.com/repos/Yinaura/jagi/hooks","issue_events_url":"https://api.github.com/repos/Yinaura/jagi/issues/events{/number}","events_url":"https://api.github.com/repos/Yinaura/jagi/events","assignees_url":"https://api.github.com/repos/Yinaura/jagi/assignees{/user}","branches_url":"https://api.github.com/repos/Yinaura/jagi/branches{/branch}","tags_url":"https://api.github.com/repos/Yinaura/jagi/tags","blobs_url":"https://api.github.com/repos/Yinaura/jagi/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Yinaura/jagi/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Yinaura/jagi/git/refs{/sha}","trees_url":"https://api.github.com/repos/Yinaura/jagi/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Yinaura/jagi/statuses/{sha}","languages_url":"https://api.github.com/repos/Yinaura/jagi/languages","stargazers_url":"https://api.github.com/repos/Yinaura/jagi/stargazers","contributors_url":"https://api.github.com/repos/Yinaura/jagi/contributors","subscribers_url":"https://api.github.com/repos/Yinaura/jagi/subscribers","subscription_url":"https://api.github.com/repos/Yinaura/jagi/subscription","commits_url":"https://api.github.com/repos/Yinaura/jagi/commits{/sha}","git_commits_url":"https://api.github.com/repos/Yinaura/jagi/git/commits{/sha}","comments_url":"https://api.github.com/repos/Yinaura/jagi/comments{/number}","issue_comment_url":"https://api.github.com/repos/Yinaura/jagi/issues/comments{/number}","contents_url":"https://api.github.com/repos/Yinaura/jagi/contents/{+path}","compare_url":"https://api.github.com/repos/Yinaura/jagi/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Yinaura/jagi/merges","archive_url":"https://api.github.com/repos/Yinaura/jagi/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Yinaura/jagi/downloads","issues_url":"https://api.github.com/repos/Yinaura/jagi/issues{/number}","pulls_url":"https://api.github.com/repos/Yinaura/jagi/pulls{/number}","milestones_url":"https://api.github.com/repos/Yinaura/jagi/milestones{/number}","notifications_url":"https://api.github.com/repos/Yinaura/jagi/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Yinaura/jagi/labels{/name}","releases_url":"https://api.github.com/repos/Yinaura/jagi/releases{/id}","created_at":"2015-08-04T02:57:51Z","updated_at":"2015-08-04T03:10:49Z","pushed_at":"2015-08-24T03:31:21Z","git_url":"git://github.com/Yinaura/jagi.git","ssh_url":"git@github.com:Yinaura/jagi.git","clone_url":"https://github.com/Yinaura/jagi.git","svn_url":"https://github.com/Yinaura/jagi","homepage":null,"size":1444,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":6,"forks":1,"open_issues":6,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Yinaura/jagi/pulls/17"},"html":{"href":"https://github.com/Yinaura/jagi/pull/17"},"issue":{"href":"https://api.github.com/repos/Yinaura/jagi/issues/17"},"comments":{"href":"https://api.github.com/repos/Yinaura/jagi/issues/17/comments"},"review_comments":{"href":"https://api.github.com/repos/Yinaura/jagi/pulls/17/comments"},"review_comment":{"href":"https://api.github.com/repos/Yinaura/jagi/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Yinaura/jagi/pulls/17/commits"},"statuses":{"href":"https://api.github.com/repos/Yinaura/jagi/statuses/3e4fd4276820224a9b94ae173937e542ce40b324"}}}}