summaryrefslogtreecommitdiff
path: root/lib/api/snippets.rb
Commit message (Collapse)AuthorAgeFilesLines
* Rewrite SnippetsFinder to improve performanceYorick Peterse2018-11-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This completely rewrites the SnippetsFinder class from the ground up in order to improve its performance. The old code was beyond salvaging. It was complex, included various Rails 5 workarounds, comments that shouldn't be necessary, and most important of all: it produced a really poorly performing database query. As a result, I opted for rewriting the finder from scratch, instead of trying to patch the existing code. Instead of trying to reuse as many existing methods as possible, I opted for defining new methods specifically meant for the SnippetsFinder. This requires some extra code here and there, but allows us to have much more control over the resulting SQL queries. It is these changes that then allow us to produce a _much_ more efficient query. To illustrate how bad the old query was, we will use my own snippets as an example. Currently I have 52 snippets, most of which are global ones. To retrieve these, you would run the following Ruby code: user = User.find_by(username: 'yorickpeterse') SnippetsFinder.new(user, author: user).execute On GitLab.com the resulting query will take between 10 and 15 seconds to run, producing the query plan found at https://explain.depesz.com/s/Y5IX. Apart from the long execution time, the total number of buffers (the sum of all shared hits) is around 185 GB, though the real number is probably (hopefully) much lower as I doubt simply summing these numbers produces the true total number of buffers used. The new query's plan can be found at https://explain.depesz.com/s/wHdN, and this query takes between 10 and 100-ish milliseconds to run. The total number of buffers used is only about 30 MB. Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/52639
* Enable frozen string in lib/api and lib/backupgfyoung2018-09-291-0/+2
| | | | | | | | | | Partially addresses #47424. Had to make changes to spec files because stubbing methods on frozen objects is a mess in RSpec and leads to failures: https://github.com/rspec/rspec-mocks/issues/1190
* Disable existing offenses for the CodeReuse copsYorick Peterse2018-09-111-0/+8
| | | | | This whitelists all existing offenses for the various CodeReuse cops, of which most are triggered by the CodeReuse/ActiveRecord cop.
* Resolve "Make a Rubocop that forbids returning from a block"🙈 jacopo beschi 🙉2018-04-181-4/+4
|
* Adds Rubocop rule for line break after guard clauseJacopo2017-11-161-0/+1
| | | | Adds a rubocop rule (with autocorrect) to ensure line break after guard clauses.
* Conditionally destroy a ressourceRobert Schilling2017-08-281-3/+1
|
* API: Respect the 'If-Unmodified-Since' for delete endpointsRobert Schilling2017-08-281-0/+1
|
* Update grape gemdz-update-grapeDmitriy Zaporozhets2017-07-201-0/+1
| | | | | | | | New version of the gem returns 200 status code on delete with content instead of 204 so we explicitly set status code to keep existing behavior Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
* refactor code based on feedbackJames Lopez2017-07-061-2/+1
|
* add user agent details API endpoints to issues and snippetsJames Lopez2017-07-061-0/+17
|
* Support descriptions for snippetsJarka Kadlecova2017-05-311-0/+2
|
* Merge branch 'snippets-finder-visibility' into 'security'Douwe Maan2017-05-101-2/+2
| | | | | | Refactor snippets finder & dont return internal snippets for external users See merge request !2094
* Use string based `visibility` getter & setterToon Claes2017-03-021-2/+2
| | | | | | Add `visibility` & `visibility=` methods to the `Gitlab::VisibilityLevel` module so the `visibility_level` can be get/set with a string value.
* Expose Snippet VisibilityLevel as StringToon Claes2017-03-021-10/+10
|
* Return 204 for delete endpointsRobert Schilling2017-02-281-1/+2
|
* Spam check and reCAPTCHA improvements28093-snippet-and-issue-spam-check-on-editOswaldo Ferreira2017-02-211-1/+6
|
* Check public snippets for spamSean McGivern2017-02-021-1/+1
| | | | | | Apply the same spam checks to public snippets (either personal snippets that are public, or public snippets on public projects) as to issues on public projects.
* API: Endpoint to expose personal snippets as /snippetsGuyzmo2016-12-011-0/+137
Adding the necessary API for the new /snippets Restful resource added with this commit. Added a new Grape class `Snippets`, as well as a `PersonalSnippet` entity. Issue: #20042 Merge-Request: !6373 Signed-off-by: Guyzmo <guyzmo+gitlab+pub@m0g.net>