{"action":"created","comment":{"url":"https://api.github.com/repos/wagn/wikirate/pulls/comments/80334679","id":80334679,"diff_hunk":"@@ -6,103 +6,50 @@ def filter_by_key key\n   filter_by_metric key\n end\n \n+def filter_by_values values\n+  filter_by_value(values) &&\n+    filter_by_year(values)\n+end\n+\n def filter_by_metric metric\n   filter_by_name(metric) &&\n     filter_by_topic(metric) &&\n     filter_by_research_policy(metric) &&\n     filter_by_vote(metric) &&\n-    filter_by_type(metric)\n-end\n-\n-def filter_by_name metric\n-  return true unless Env.params[\"name\"].present?\n-  metric.downcase.include?(Env.params[\"name\"].downcase)\n-end\n-\n-def filter_by_topic metric\n-  return true unless Env.params[\"wikirate_topic\"].present?\n-  topic_cards = Card[metric].fetch trait: :wikirate_topic\n-  topic_cards && topic_cards.item_names.include?(Env.params[\"wikirate_topic\"])\n-end\n-\n-def filter_by_research_policy metric\n-  research_policy = Env.params[\"research_policy\"]\n-  return true if !research_policy.present? || research_policy.size == 2\n-  rp_card = Card[metric].fetch trait: :research_policy, new: {}\n-  rp_card &&\n-    rp_card.item_names.any? { |s| s.casecmp(research_policy[0]).zero? }\n+    filter_by_metric_type(metric)\n end\n \n def filter_by_vote metric\n-  vote_param = Env.params[\"my_vote\"]\n-  return true if !vote_param.present? || vote_param.size == 3\n-  upvoted = upvoted_metric?(metric)\n-  downvoted = downvoted_metric?(metric)\n-  fit_vote? upvoted, downvoted, vote_param\n-end\n-\n-def filter_by_type metric\n-  return true unless Env.params[\"type\"].present?\n-  return false if Card[metric].type_id != MetricID\n-  mt = Card[metric].metric_type\n-  Env.params[\"type\"].any? { |s| s.casecmp(mt).zero? }\n-end\n-\n-def filter_by_value values\n-  unit =\n-    if Env.params[\"value\"].present?\n-      Env.params[\"value\"]\n-    else\n-      \"exists\"\n+  keep_if :my_vote, options: 3 do |filter|\n+    case vote_status metric\n+    when :upvoted   then filter.include? \"i voted for\"\n+    when :downvoted then filter.include? \"i voted against\"\n+    else filter.include? \"i did not vote\"\n     end\n-  return values.empty? if unit == \"none\"\n-  return !values.empty? if unit == \"exists\"\n-  within_recent? unit, values\n-end\n-\n-def filter_by_year values\n-  return true unless Env.params[\"year\"].present?\n-  values.any? { |v| v[\"year\"] == Env.params[\"year\"] }\n+  end\n end\n \n private\n \n-def fit_vote? upvoted, downvoted, vote_param\n-  not_voted = !upvoted && !downvoted\n-  result = false\n-  result |= upvoted if vote_param.include?(\"i voted for\")\n-  result |= downvoted if vote_param.include?(\"i voted against\")\n-  result |= not_voted if vote_param.include?(\"i did not vote\")\n-  result\n+def vote_status metric\n+  if upvoted_metric? metric\n+    :upvoted\n+  elsif downvoted_metric? metric\n+    :downvoted\n+  end\n end\n \n def upvoted_metric? metric\n-  @upvoted_metric ||= user_voted_metric(\"upvotee\")\n-  @upvoted_metric.include?(metric)\n+  @upvoted_metrics ||= ::Set.new user_voted_metric(\"upvotee\")\n+  @upvoted_metrics.include? metric\n end\n \n def downvoted_metric? metric\n-  @downvoted_metric ||= user_voted_metric(\"downvotee\")\n-  @downvoted_metric.include?(metric)\n+  @downvoted_metrics ||= ::Set.new user_voted_metric(\"downvotee\")\n+  @downvoted_metrics.include? metric\n end\n \n-def within_recent? unit, values\n-  time_diff = second_by_unit unit\n-  time_now = Time.now.to_i\n-  values.any? do |v|\n-    time_now - v[\"last_update_time\"] <= time_diff\n-  end\n-end\n-\n-def second_by_unit unit\n-  case unit\n-  when \"last_hour\"\n-    3600\n-  when \"today\"\n-    86_400\n-  when \"week\"\n-    604_800\n-  when \"month\"\n-    2_592_000\n-  end\n-end\n+def user_voted_metric votee_type\n+  votee_search = \"#{Auth.current.name}+metric+#{votee_type}_search\"\n+  Card.fetch(votee_search).item_names\n+end","path":"mod/01_rating/set/type_plus_right/wikirate_company/all_metric_values/filter.rb","position":129,"original_position":129,"commit_id":"b4d9134816adfcd39629ed6a05e8d0daad8102fa","original_commit_id":"b4d9134816adfcd39629ed6a05e8d0daad8102fa","user":{"login":"houndci-bot","id":6697940,"avatar_url":"https://avatars.githubusercontent.com/u/6697940?v=3","gravatar_id":"","url":"https://api.github.com/users/houndci-bot","html_url":"https://github.com/houndci-bot","followers_url":"https://api.github.com/users/houndci-bot/followers","following_url":"https://api.github.com/users/houndci-bot/following{/other_user}","gists_url":"https://api.github.com/users/houndci-bot/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci-bot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci-bot/subscriptions","organizations_url":"https://api.github.com/users/houndci-bot/orgs","repos_url":"https://api.github.com/users/houndci-bot/repos","events_url":"https://api.github.com/users/houndci-bot/events{/privacy}","received_events_url":"https://api.github.com/users/houndci-bot/received_events","type":"User","site_admin":false},"body":"Final newline missing.","created_at":"2016-09-23T22:00:48Z","updated_at":"2016-09-23T22:00:48Z","html_url":"https://github.com/wagn/wikirate/pull/503#discussion_r80334679","pull_request_url":"https://api.github.com/repos/wagn/wikirate/pulls/503","_links":{"self":{"href":"https://api.github.com/repos/wagn/wikirate/pulls/comments/80334679"},"html":{"href":"https://github.com/wagn/wikirate/pull/503#discussion_r80334679"},"pull_request":{"href":"https://api.github.com/repos/wagn/wikirate/pulls/503"}}},"pull_request":{"url":"https://api.github.com/repos/wagn/wikirate/pulls/503","id":86521359,"html_url":"https://github.com/wagn/wikirate/pull/503","diff_url":"https://github.com/wagn/wikirate/pull/503.diff","patch_url":"https://github.com/wagn/wikirate/pull/503.patch","issue_url":"https://api.github.com/repos/wagn/wikirate/issues/503","number":503,"state":"open","locked":false,"title":"all_metrics and all_companies","user":{"login":"xithan","id":13584,"avatar_url":"https://avatars.githubusercontent.com/u/13584?v=3","gravatar_id":"","url":"https://api.github.com/users/xithan","html_url":"https://github.com/xithan","followers_url":"https://api.github.com/users/xithan/followers","following_url":"https://api.github.com/users/xithan/following{/other_user}","gists_url":"https://api.github.com/users/xithan/gists{/gist_id}","starred_url":"https://api.github.com/users/xithan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xithan/subscriptions","organizations_url":"https://api.github.com/users/xithan/orgs","repos_url":"https://api.github.com/users/xithan/repos","events_url":"https://api.github.com/users/xithan/events{/privacy}","received_events_url":"https://api.github.com/users/xithan/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-09-23T14:21:32Z","updated_at":"2016-09-23T22:00:48Z","closed_at":null,"merged_at":null,"merge_commit_sha":"80aef8667fea11922bf53f89138d0fe8b489c413","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/wagn/wikirate/pulls/503/commits","review_comments_url":"https://api.github.com/repos/wagn/wikirate/pulls/503/comments","review_comment_url":"https://api.github.com/repos/wagn/wikirate/pulls/comments{/number}","comments_url":"https://api.github.com/repos/wagn/wikirate/issues/503/comments","statuses_url":"https://api.github.com/repos/wagn/wikirate/statuses/b4d9134816adfcd39629ed6a05e8d0daad8102fa","head":{"label":"xithan:all_values","ref":"all_values","sha":"b4d9134816adfcd39629ed6a05e8d0daad8102fa","user":{"login":"xithan","id":13584,"avatar_url":"https://avatars.githubusercontent.com/u/13584?v=3","gravatar_id":"","url":"https://api.github.com/users/xithan","html_url":"https://github.com/xithan","followers_url":"https://api.github.com/users/xithan/followers","following_url":"https://api.github.com/users/xithan/following{/other_user}","gists_url":"https://api.github.com/users/xithan/gists{/gist_id}","starred_url":"https://api.github.com/users/xithan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xithan/subscriptions","organizations_url":"https://api.github.com/users/xithan/orgs","repos_url":"https://api.github.com/users/xithan/repos","events_url":"https://api.github.com/users/xithan/events{/privacy}","received_events_url":"https://api.github.com/users/xithan/received_events","type":"User","site_admin":false},"repo":{"id":20190741,"name":"wikirate","full_name":"xithan/wikirate","owner":{"login":"xithan","id":13584,"avatar_url":"https://avatars.githubusercontent.com/u/13584?v=3","gravatar_id":"","url":"https://api.github.com/users/xithan","html_url":"https://github.com/xithan","followers_url":"https://api.github.com/users/xithan/followers","following_url":"https://api.github.com/users/xithan/following{/other_user}","gists_url":"https://api.github.com/users/xithan/gists{/gist_id}","starred_url":"https://api.github.com/users/xithan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xithan/subscriptions","organizations_url":"https://api.github.com/users/xithan/orgs","repos_url":"https://api.github.com/users/xithan/repos","events_url":"https://api.github.com/users/xithan/events{/privacy}","received_events_url":"https://api.github.com/users/xithan/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/xithan/wikirate","description":"","fork":true,"url":"https://api.github.com/repos/xithan/wikirate","forks_url":"https://api.github.com/repos/xithan/wikirate/forks","keys_url":"https://api.github.com/repos/xithan/wikirate/keys{/key_id}","collaborators_url":"https://api.github.com/repos/xithan/wikirate/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/xithan/wikirate/teams","hooks_url":"https://api.github.com/repos/xithan/wikirate/hooks","issue_events_url":"https://api.github.com/repos/xithan/wikirate/issues/events{/number}","events_url":"https://api.github.com/repos/xithan/wikirate/events","assignees_url":"https://api.github.com/repos/xithan/wikirate/assignees{/user}","branches_url":"https://api.github.com/repos/xithan/wikirate/branches{/branch}","tags_url":"https://api.github.com/repos/xithan/wikirate/tags","blobs_url":"https://api.github.com/repos/xithan/wikirate/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/xithan/wikirate/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/xithan/wikirate/git/refs{/sha}","trees_url":"https://api.github.com/repos/xithan/wikirate/git/trees{/sha}","statuses_url":"https://api.github.com/repos/xithan/wikirate/statuses/{sha}","languages_url":"https://api.github.com/repos/xithan/wikirate/languages","stargazers_url":"https://api.github.com/repos/xithan/wikirate/stargazers","contributors_url":"https://api.github.com/repos/xithan/wikirate/contributors","subscribers_url":"https://api.github.com/repos/xithan/wikirate/subscribers","subscription_url":"https://api.github.com/repos/xithan/wikirate/subscription","commits_url":"https://api.github.com/repos/xithan/wikirate/commits{/sha}","git_commits_url":"https://api.github.com/repos/xithan/wikirate/git/commits{/sha}","comments_url":"https://api.github.com/repos/xithan/wikirate/comments{/number}","issue_comment_url":"https://api.github.com/repos/xithan/wikirate/issues/comments{/number}","contents_url":"https://api.github.com/repos/xithan/wikirate/contents/{+path}","compare_url":"https://api.github.com/repos/xithan/wikirate/compare/{base}...{head}","merges_url":"https://api.github.com/repos/xithan/wikirate/merges","archive_url":"https://api.github.com/repos/xithan/wikirate/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/xithan/wikirate/downloads","issues_url":"https://api.github.com/repos/xithan/wikirate/issues{/number}","pulls_url":"https://api.github.com/repos/xithan/wikirate/pulls{/number}","milestones_url":"https://api.github.com/repos/xithan/wikirate/milestones{/number}","notifications_url":"https://api.github.com/repos/xithan/wikirate/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/xithan/wikirate/labels{/name}","releases_url":"https://api.github.com/repos/xithan/wikirate/releases{/id}","deployments_url":"https://api.github.com/repos/xithan/wikirate/deployments","created_at":"2014-05-26T15:35:11Z","updated_at":"2016-09-06T07:35:28Z","pushed_at":"2016-09-23T22:00:35Z","git_url":"git://github.com/xithan/wikirate.git","ssh_url":"git@github.com:xithan/wikirate.git","clone_url":"https://github.com/xithan/wikirate.git","svn_url":"https://github.com/xithan/wikirate","homepage":null,"size":99578,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"wagn:master","ref":"master","sha":"e854917aa08db4f5fc62bfd2fe604d39af9f5d52","user":{"login":"wagn","id":20722,"avatar_url":"https://avatars.githubusercontent.com/u/20722?v=3","gravatar_id":"","url":"https://api.github.com/users/wagn","html_url":"https://github.com/wagn","followers_url":"https://api.github.com/users/wagn/followers","following_url":"https://api.github.com/users/wagn/following{/other_user}","gists_url":"https://api.github.com/users/wagn/gists{/gist_id}","starred_url":"https://api.github.com/users/wagn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wagn/subscriptions","organizations_url":"https://api.github.com/users/wagn/orgs","repos_url":"https://api.github.com/users/wagn/repos","events_url":"https://api.github.com/users/wagn/events{/privacy}","received_events_url":"https://api.github.com/users/wagn/received_events","type":"User","site_admin":false},"repo":{"id":15884166,"name":"wikirate","full_name":"wagn/wikirate","owner":{"login":"wagn","id":20722,"avatar_url":"https://avatars.githubusercontent.com/u/20722?v=3","gravatar_id":"","url":"https://api.github.com/users/wagn","html_url":"https://github.com/wagn","followers_url":"https://api.github.com/users/wagn/followers","following_url":"https://api.github.com/users/wagn/following{/other_user}","gists_url":"https://api.github.com/users/wagn/gists{/gist_id}","starred_url":"https://api.github.com/users/wagn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wagn/subscriptions","organizations_url":"https://api.github.com/users/wagn/orgs","repos_url":"https://api.github.com/users/wagn/repos","events_url":"https://api.github.com/users/wagn/events{/privacy}","received_events_url":"https://api.github.com/users/wagn/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/wagn/wikirate","description":"","fork":false,"url":"https://api.github.com/repos/wagn/wikirate","forks_url":"https://api.github.com/repos/wagn/wikirate/forks","keys_url":"https://api.github.com/repos/wagn/wikirate/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wagn/wikirate/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wagn/wikirate/teams","hooks_url":"https://api.github.com/repos/wagn/wikirate/hooks","issue_events_url":"https://api.github.com/repos/wagn/wikirate/issues/events{/number}","events_url":"https://api.github.com/repos/wagn/wikirate/events","assignees_url":"https://api.github.com/repos/wagn/wikirate/assignees{/user}","branches_url":"https://api.github.com/repos/wagn/wikirate/branches{/branch}","tags_url":"https://api.github.com/repos/wagn/wikirate/tags","blobs_url":"https://api.github.com/repos/wagn/wikirate/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wagn/wikirate/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wagn/wikirate/git/refs{/sha}","trees_url":"https://api.github.com/repos/wagn/wikirate/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wagn/wikirate/statuses/{sha}","languages_url":"https://api.github.com/repos/wagn/wikirate/languages","stargazers_url":"https://api.github.com/repos/wagn/wikirate/stargazers","contributors_url":"https://api.github.com/repos/wagn/wikirate/contributors","subscribers_url":"https://api.github.com/repos/wagn/wikirate/subscribers","subscription_url":"https://api.github.com/repos/wagn/wikirate/subscription","commits_url":"https://api.github.com/repos/wagn/wikirate/commits{/sha}","git_commits_url":"https://api.github.com/repos/wagn/wikirate/git/commits{/sha}","comments_url":"https://api.github.com/repos/wagn/wikirate/comments{/number}","issue_comment_url":"https://api.github.com/repos/wagn/wikirate/issues/comments{/number}","contents_url":"https://api.github.com/repos/wagn/wikirate/contents/{+path}","compare_url":"https://api.github.com/repos/wagn/wikirate/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wagn/wikirate/merges","archive_url":"https://api.github.com/repos/wagn/wikirate/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wagn/wikirate/downloads","issues_url":"https://api.github.com/repos/wagn/wikirate/issues{/number}","pulls_url":"https://api.github.com/repos/wagn/wikirate/pulls{/number}","milestones_url":"https://api.github.com/repos/wagn/wikirate/milestones{/number}","notifications_url":"https://api.github.com/repos/wagn/wikirate/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wagn/wikirate/labels{/name}","releases_url":"https://api.github.com/repos/wagn/wikirate/releases{/id}","deployments_url":"https://api.github.com/repos/wagn/wikirate/deployments","created_at":"2014-01-13T22:29:39Z","updated_at":"2016-05-07T04:55:35Z","pushed_at":"2016-09-23T22:00:35Z","git_url":"git://github.com/wagn/wikirate.git","ssh_url":"git@github.com:wagn/wikirate.git","clone_url":"https://github.com/wagn/wikirate.git","svn_url":"https://github.com/wagn/wikirate","homepage":null,"size":99615,"stargazers_count":2,"watchers_count":2,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":2,"forks":5,"open_issues":2,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/wagn/wikirate/pulls/503"},"html":{"href":"https://github.com/wagn/wikirate/pull/503"},"issue":{"href":"https://api.github.com/repos/wagn/wikirate/issues/503"},"comments":{"href":"https://api.github.com/repos/wagn/wikirate/issues/503/comments"},"review_comments":{"href":"https://api.github.com/repos/wagn/wikirate/pulls/503/comments"},"review_comment":{"href":"https://api.github.com/repos/wagn/wikirate/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/wagn/wikirate/pulls/503/commits"},"statuses":{"href":"https://api.github.com/repos/wagn/wikirate/statuses/b4d9134816adfcd39629ed6a05e8d0daad8102fa"}}}}
{"actor":{"display_login":"houndci-bot"}}