GitHub PullRequestReviewCommentEvent at 2014-08-29 20:54:26
Repository: gitlabhq
Actor: houndci
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/gitlabhq/gitlabhq/pulls/comments/16920318","id":16920318,"diff_hunk":"@@ -0,0 +1,100 @@\n+module Gitlab\n+  class SnippetSearchResults < SearchResults\n+    attr_reader :limit_snippet_ids\n+\n+    def initialize(limit_snippet_ids, query)\n+      @limit_snippet_ids = limit_snippet_ids\n+      @query = query\n+    end\n+\n+    def objects(scope, page = nil)\n+      case scope\n+      when 'snippet_titles'\n+        Kaminari.paginate_array(snippet_titles).page(page).per(per_page)\n+      when 'snippet_blobs'\n+        Kaminari.paginate_array(snippet_blobs).page(page).per(per_page)\n+      else\n+        super\n+      end\n+    end\n+\n+    def total_count\n+      @total_count ||= snippet_titles_count + snippet_blobs_count\n+    end\n+\n+    def snippet_titles_count\n+      @snippet_titles_count ||= snippet_titles.count\n+    end\n+\n+    def snippet_blobs_count\n+      @snippet_blobs_count ||= snippet_blobs.count\n+    end\n+\n+    private\n+\n+    def snippet_titles\n+      Snippet.where(id: limit_snippet_ids).search(query).order('updated_at DESC')\n+    end\n+\n+    def snippet_blobs\n+      matching_snippets = Snippet.where(id: limit_snippet_ids).search_code(query).order('updated_at DESC')\n+      matching_snippets = matching_snippets.to_a\n+      snippets = []\n+      matching_snippets.each { |e| snippets << chunk_snippet(e) }\n+      snippets\n+    end\n+\n+    def default_scope\n+      'snippet_blobs'\n+    end\n+\n+    def bounded_line_numbers(line, min, max, surrounding_lines)\n+      lower = line - surrounding_lines > min ? line - surrounding_lines : min\n+      upper = line + surrounding_lines < max ? line + surrounding_lines : max\n+      (lower..upper).to_a\n+    end\n+\n+    def chunk_snippet(snippet)\n+      surrounding_lines = 3\n+      used_lines = []\n+      lined_content = snippet.content.split(\"\\n\")\n+      lined_content.each_with_index { |line, line_number|","path":"lib/gitlab/snippet_search_results.rb","position":61,"original_position":61,"commit_id":"4cca1b050a0e80e4ce6bb67f530549a2f28af630","original_commit_id":"4cca1b050a0e80e4ce6bb67f530549a2f28af630","user":{"login":"houndci","id":6697940,"avatar_url":"https://avatars.githubusercontent.com/u/6697940?v=2","gravatar_id":"38d9cefd9971a05bf447f07c6cd332cc","url":"https://api.github.com/users/houndci","html_url":"https://github.com/houndci","followers_url":"https://api.github.com/users/houndci/followers","following_url":"https://api.github.com/users/houndci/following{/other_user}","gists_url":"https://api.github.com/users/houndci/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci/subscriptions","organizations_url":"https://api.github.com/users/houndci/orgs","repos_url":"https://api.github.com/users/houndci/repos","events_url":"https://api.github.com/users/houndci/events{/privacy}","received_events_url":"https://api.github.com/users/houndci/received_events","type":"User","site_admin":false},"body":"Avoid using {...} for multi-line blocks.","created_at":"2014-08-29T20:54:26Z","updated_at":"2014-08-29T20:54:26Z","html_url":"https://github.com/gitlabhq/gitlabhq/pull/7646#discussion_r16920318","pull_request_url":"https://api.github.com/repos/gitlabhq/gitlabhq/pulls/7646","_links":{"self":{"href":"https://api.github.com/repos/gitlabhq/gitlabhq/pulls/comments/16920318"},"html":{"href":"https://github.com/gitlabhq/gitlabhq/pull/7646#discussion_r16920318"},"pull_request":{"href":"https://api.github.com/repos/gitlabhq/gitlabhq/pulls/7646"}}},"pull_request":{"url":"https://api.github.com/repos/gitlabhq/gitlabhq/pulls/7646","id":20522809,"html_url":"https://github.com/gitlabhq/gitlabhq/pull/7646","diff_url":"https://github.com/gitlabhq/gitlabhq/pull/7646.diff","patch_url":"https://github.com/gitlabhq/gitlabhq/pull/7646.patch","issue_url":"https://api.github.com/repos/gitlabhq/gitlabhq/issues/7646","number":7646,"state":"open","locked":false,"title":"Adding in snippet search functionality","user":{"login":"bushong1","id":236700,"avatar_url":"https://avatars.githubusercontent.com/u/236700?v=2","gravatar_id":"21c9499fdc5687ca14e26e8a9e8f52e8","url":"https://api.github.com/users/bushong1","html_url":"https://github.com/bushong1","followers_url":"https://api.github.com/users/bushong1/followers","following_url":"https://api.github.com/users/bushong1/following{/other_user}","gists_url":"https://api.github.com/users/bushong1/gists{/gist_id}","starred_url":"https://api.github.com/users/bushong1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bushong1/subscriptions","organizations_url":"https://api.github.com/users/bushong1/orgs","repos_url":"https://api.github.com/users/bushong1/repos","events_url":"https://api.github.com/users/bushong1/events{/privacy}","received_events_url":"https://api.github.com/users/bushong1/received_events","type":"User","site_admin":false},"body":"This is a resubmit of the closed PR#7612.  While fixing some things, a refactor of search was pushed to master.  This PR is updating snippet-search for the refactor.\r\n\r\nIn reference to this merge request:\r\n\r\nhttp://feedback.gitlab.com/forums/176466-general/suggestions/5529795-search-though-snippets\r\n\r\n##### What does this MR do?\r\nAdds the capability to search snippets.  This can be accessed  whenever viewing a snippet related page, such as personal snippets, snippet discovery, and search snippets.  There is a tab for searching just filenames and titles, and there is a tab for searching just the code of the snippet.  It searches all public snippets, as well as the private snippets of the user.\r\n\r\n##### Are there points in the code the reviewer needs to double check?\r\nThe largest change outside of haml files is lib/gitlab/snippet_search_results.rb.  \r\n\r\n##### Why was this MR needed?\r\nThis is something my users have been asking for, and it should add a great amount of collaborative capability and global discovery to the snippets feature.  In addition, there is a merge request already created with over 20 points.\r\n\r\n##### What are the relevant issue numbers / Feature requests?\r\nhttp://feedback.gitlab.com/forums/176466-general/suggestions/5529795-search-though-snippets\r\n\r\n##### Screenshots (If appropiate)\r\n\r\n![selection_014](https://cloud.githubusercontent.com/assets/236700/4096176/dbcb1d0e-2fbd-11e4-91bb-16835ba93e6b.png)\r\n![selection_015](https://cloud.githubusercontent.com/assets/236700/4096178/dbce326e-2fbd-11e4-830f-f86f158491df.png)\r\n![selection_016](https://cloud.githubusercontent.com/assets/236700/4096180/dbd1689e-2fbd-11e4-9ff9-3be0614ba718.png)\r\n![selection_017](https://cloud.githubusercontent.com/assets/236700/4096177/dbcde70a-2fbd-11e4-91c0-108b0fab6aa5.png)\r\n![selection_018](https://cloud.githubusercontent.com/assets/236700/4096179/dbcef47e-2fbd-11e4-986f-0d9f3bcb9c29.png)\r\n![selection_019](https://cloud.githubusercontent.com/assets/236700/4096181/dbd8a17c-2fbd-11e4-8d02-fdcda553f1d9.png)","created_at":"2014-08-29T20:54:22Z","updated_at":"2014-08-29T20:54:26Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bbb8100f2824b55732f90e031d4af973cd814729","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/gitlabhq/gitlabhq/pulls/7646/commits","review_comments_url":"https://api.github.com/repos/gitlabhq/gitlabhq/pulls/7646/comments","review_comment_url":"https://api.github.com/repos/gitlabhq/gitlabhq/pulls/comments/{number}","comments_url":"https://api.github.com/repos/gitlabhq/gitlabhq/issues/7646/comments","statuses_url":"https://api.github.com/repos/gitlabhq/gitlabhq/statuses/4cca1b050a0e80e4ce6bb67f530549a2f28af630","head":{"label":"bushong1:snippet-search3","ref":"snippet-search3","sha":"4cca1b050a0e80e4ce6bb67f530549a2f28af630","user":{"login":"bushong1","id":236700,"avatar_url":"https://avatars.githubusercontent.com/u/236700?v=2","gravatar_id":"21c9499fdc5687ca14e26e8a9e8f52e8","url":"https://api.github.com/users/bushong1","html_url":"https://github.com/bushong1","followers_url":"https://api.github.com/users/bushong1/followers","following_url":"https://api.github.com/users/bushong1/following{/other_user}","gists_url":"https://api.github.com/users/bushong1/gists{/gist_id}","starred_url":"https://api.github.com/users/bushong1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bushong1/subscriptions","organizations_url":"https://api.github.com/users/bushong1/orgs","repos_url":"https://api.github.com/users/bushong1/repos","events_url":"https://api.github.com/users/bushong1/events{/privacy}","received_events_url":"https://api.github.com/users/bushong1/received_events","type":"User","site_admin":false},"repo":{"id":18221016,"name":"gitlabhq","full_name":"bushong1/gitlabhq","owner":{"login":"bushong1","id":236700,"avatar_url":"https://avatars.githubusercontent.com/u/236700?v=2","gravatar_id":"21c9499fdc5687ca14e26e8a9e8f52e8","url":"https://api.github.com/users/bushong1","html_url":"https://github.com/bushong1","followers_url":"https://api.github.com/users/bushong1/followers","following_url":"https://api.github.com/users/bushong1/following{/other_user}","gists_url":"https://api.github.com/users/bushong1/gists{/gist_id}","starred_url":"https://api.github.com/users/bushong1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bushong1/subscriptions","organizations_url":"https://api.github.com/users/bushong1/orgs","repos_url":"https://api.github.com/users/bushong1/repos","events_url":"https://api.github.com/users/bushong1/events{/privacy}","received_events_url":"https://api.github.com/users/bushong1/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bushong1/gitlabhq","description":"Project management and code hosting  application. Follow us on twitter @gitlabhq","fork":true,"url":"https://api.github.com/repos/bushong1/gitlabhq","forks_url":"https://api.github.com/repos/bushong1/gitlabhq/forks","keys_url":"https://api.github.com/repos/bushong1/gitlabhq/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bushong1/gitlabhq/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bushong1/gitlabhq/teams","hooks_url":"https://api.github.com/repos/bushong1/gitlabhq/hooks","issue_events_url":"https://api.github.com/repos/bushong1/gitlabhq/issues/events{/number}","events_url":"https://api.github.com/repos/bushong1/gitlabhq/events","assignees_url":"https://api.github.com/repos/bushong1/gitlabhq/assignees{/user}","branches_url":"https://api.github.com/repos/bushong1/gitlabhq/branches{/branch}","tags_url":"https://api.github.com/repos/bushong1/gitlabhq/tags","blobs_url":"https://api.github.com/repos/bushong1/gitlabhq/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bushong1/gitlabhq/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bushong1/gitlabhq/git/refs{/sha}","trees_url":"https://api.github.com/repos/bushong1/gitlabhq/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bushong1/gitlabhq/statuses/{sha}","languages_url":"https://api.github.com/repos/bushong1/gitlabhq/languages","stargazers_url":"https://api.github.com/repos/bushong1/gitlabhq/stargazers","contributors_url":"https://api.github.com/repos/bushong1/gitlabhq/contributors","subscribers_url":"https://api.github.com/repos/bushong1/gitlabhq/subscribers","subscription_url":"https://api.github.com/repos/bushong1/gitlabhq/subscription","commits_url":"https://api.github.com/repos/bushong1/gitlabhq/commits{/sha}","git_commits_url":"https://api.github.com/repos/bushong1/gitlabhq/git/commits{/sha}","comments_url":"https://api.github.com/repos/bushong1/gitlabhq/comments{/number}","issue_comment_url":"https://api.github.com/repos/bushong1/gitlabhq/issues/comments/{number}","contents_url":"https://api.github.com/repos/bushong1/gitlabhq/contents/{+path}","compare_url":"https://api.github.com/repos/bushong1/gitlabhq/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bushong1/gitlabhq/merges","archive_url":"https://api.github.com/repos/bushong1/gitlabhq/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bushong1/gitlabhq/downloads","issues_url":"https://api.github.com/repos/bushong1/gitlabhq/issues{/number}","pulls_url":"https://api.github.com/repos/bushong1/gitlabhq/pulls{/number}","milestones_url":"https://api.github.com/repos/bushong1/gitlabhq/milestones{/number}","notifications_url":"https://api.github.com/repos/bushong1/gitlabhq/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bushong1/gitlabhq/labels{/name}","releases_url":"https://api.github.com/repos/bushong1/gitlabhq/releases{/id}","created_at":"2014-03-28T17:46:39Z","updated_at":"2014-08-26T21:23:04Z","pushed_at":"2014-08-29T20:44:40Z","git_url":"git://github.com/bushong1/gitlabhq.git","ssh_url":"git@github.com:bushong1/gitlabhq.git","clone_url":"https://github.com/bushong1/gitlabhq.git","svn_url":"https://github.com/bushong1/gitlabhq","homepage":"gitlab.org","size":82073,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"gitlabhq:master","ref":"master","sha":"d7b66e60d247f2253442f86509b16bd9a53579cb","user":{"login":"gitlabhq","id":1086321,"avatar_url":"https://avatars.githubusercontent.com/u/1086321?v=2","gravatar_id":"95b7f387358639ec09184a76151bc690","url":"https://api.github.com/users/gitlabhq","html_url":"https://github.com/gitlabhq","followers_url":"https://api.github.com/users/gitlabhq/followers","following_url":"https://api.github.com/users/gitlabhq/following{/other_user}","gists_url":"https://api.github.com/users/gitlabhq/gists{/gist_id}","starred_url":"https://api.github.com/users/gitlabhq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gitlabhq/subscriptions","organizations_url":"https://api.github.com/users/gitlabhq/orgs","repos_url":"https://api.github.com/users/gitlabhq/repos","events_url":"https://api.github.com/users/gitlabhq/events{/privacy}","received_events_url":"https://api.github.com/users/gitlabhq/received_events","type":"Organization","site_admin":false},"repo":{"id":2500088,"name":"gitlabhq","full_name":"gitlabhq/gitlabhq","owner":{"login":"gitlabhq","id":1086321,"avatar_url":"https://avatars.githubusercontent.com/u/1086321?v=2","gravatar_id":"95b7f387358639ec09184a76151bc690","url":"https://api.github.com/users/gitlabhq","html_url":"https://github.com/gitlabhq","followers_url":"https://api.github.com/users/gitlabhq/followers","following_url":"https://api.github.com/users/gitlabhq/following{/other_user}","gists_url":"https://api.github.com/users/gitlabhq/gists{/gist_id}","starred_url":"https://api.github.com/users/gitlabhq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gitlabhq/subscriptions","organizations_url":"https://api.github.com/users/gitlabhq/orgs","repos_url":"https://api.github.com/users/gitlabhq/repos","events_url":"https://api.github.com/users/gitlabhq/events{/privacy}","received_events_url":"https://api.github.com/users/gitlabhq/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/gitlabhq/gitlabhq","description":"Open source software to collaborate on code. Follow us on twitter @gitlabhq","fork":false,"url":"https://api.github.com/repos/gitlabhq/gitlabhq","forks_url":"https://api.github.com/repos/gitlabhq/gitlabhq/forks","keys_url":"https://api.github.com/repos/gitlabhq/gitlabhq/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gitlabhq/gitlabhq/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gitlabhq/gitlabhq/teams","hooks_url":"https://api.github.com/repos/gitlabhq/gitlabhq/hooks","issue_events_url":"https://api.github.com/repos/gitlabhq/gitlabhq/issues/events{/number}","events_url":"https://api.github.com/repos/gitlabhq/gitlabhq/events","assignees_url":"https://api.github.com/repos/gitlabhq/gitlabhq/assignees{/user}","branches_url":"https://api.github.com/repos/gitlabhq/gitlabhq/branches{/branch}","tags_url":"https://api.github.com/repos/gitlabhq/gitlabhq/tags","blobs_url":"https://api.github.com/repos/gitlabhq/gitlabhq/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gitlabhq/gitlabhq/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gitlabhq/gitlabhq/git/refs{/sha}","trees_url":"https://api.github.com/repos/gitlabhq/gitlabhq/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gitlabhq/gitlabhq/statuses/{sha}","languages_url":"https://api.github.com/repos/gitlabhq/gitlabhq/languages","stargazers_url":"https://api.github.com/repos/gitlabhq/gitlabhq/stargazers","contributors_url":"https://api.github.com/repos/gitlabhq/gitlabhq/contributors","subscribers_url":"https://api.github.com/repos/gitlabhq/gitlabhq/subscribers","subscription_url":"https://api.github.com/repos/gitlabhq/gitlabhq/subscription","commits_url":"https://api.github.com/repos/gitlabhq/gitlabhq/commits{/sha}","git_commits_url":"https://api.github.com/repos/gitlabhq/gitlabhq/git/commits{/sha}","comments_url":"https://api.github.com/repos/gitlabhq/gitlabhq/comments{/number}","issue_comment_url":"https://api.github.com/repos/gitlabhq/gitlabhq/issues/comments/{number}","contents_url":"https://api.github.com/repos/gitlabhq/gitlabhq/contents/{+path}","compare_url":"https://api.github.com/repos/gitlabhq/gitlabhq/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gitlabhq/gitlabhq/merges","archive_url":"https://api.github.com/repos/gitlabhq/gitlabhq/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gitlabhq/gitlabhq/downloads","issues_url":"https://api.github.com/repos/gitlabhq/gitlabhq/issues{/number}","pulls_url":"https://api.github.com/repos/gitlabhq/gitlabhq/pulls{/number}","milestones_url":"https://api.github.com/repos/gitlabhq/gitlabhq/milestones{/number}","notifications_url":"https://api.github.com/repos/gitlabhq/gitlabhq/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gitlabhq/gitlabhq/labels{/name}","releases_url":"https://api.github.com/repos/gitlabhq/gitlabhq/releases{/id}","created_at":"2011-10-02T16:25:27Z","updated_at":"2014-08-29T17:29:32Z","pushed_at":"2014-08-29T19:49:03Z","git_url":"git://github.com/gitlabhq/gitlabhq.git","ssh_url":"git@github.com:gitlabhq/gitlabhq.git","clone_url":"https://github.com/gitlabhq/gitlabhq.git","svn_url":"https://github.com/gitlabhq/gitlabhq","homepage":"https://about.gitlab.com/","size":143751,"stargazers_count":13802,"watchers_count":13802,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"forks_count":3589,"mirror_url":null,"open_issues_count":517,"forks":3589,"open_issues":517,"watchers":13802,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/gitlabhq/gitlabhq/pulls/7646"},"html":{"href":"https://github.com/gitlabhq/gitlabhq/pull/7646"},"issue":{"href":"https://api.github.com/repos/gitlabhq/gitlabhq/issues/7646"},"comments":{"href":"https://api.github.com/repos/gitlabhq/gitlabhq/issues/7646/comments"},"review_comments":{"href":"https://api.github.com/repos/gitlabhq/gitlabhq/pulls/7646/comments"},"review_comment":{"href":"https://api.github.com/repos/gitlabhq/gitlabhq/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/gitlabhq/gitlabhq/pulls/7646/commits"},"statuses":{"href":"https://api.github.com/repos/gitlabhq/gitlabhq/statuses/4cca1b050a0e80e4ce6bb67f530549a2f28af630"}}}}