summaryrefslogtreecommitdiff
path: root/app/finders/snippets_finder.rb
Commit message (Collapse)AuthorAgeFilesLines
* Add latest changes from gitlab-org/gitlab@13-12-stable-eev13.12.0-rc42GitLab Bot2021-05-191-1/+1
|
* Add latest changes from gitlab-org/gitlab@13-2-stable-eeGitLab Bot2020-07-201-3/+20
|
* Add latest changes from gitlab-org/gitlab@masterGitLab Bot2020-03-031-1/+3
|
* Add latest changes from gitlab-org/gitlab@masterGitLab Bot2019-11-281-11/+42
|
* Add latest changes from gitlab-org/gitlab@masterGitLab Bot2019-10-181-5/+16
|
* Add latest changes from gitlab-org/gitlab@masterGitLab Bot2019-10-091-8/+12
|
* Allow all personal snippets to be accessed by APINick Thomas2019-03-061-0/+2
| | | | | | Previously, you could only access personal snippets in the API if you had authored them. The documentation doesn't state that this is the case, and it's quite surprising.
* Rewrite SnippetsFinder to improve performanceYorick Peterse2018-11-051-99/+110
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Whitelist none method from ActiveRecord::Queryingda-rubocop-whitelist-active-record-noneDouglas Barbosa Alexandre2018-10-311-2/+0
|
* Added FromUnion to easily select from a UNIONYorick Peterse2018-09-171-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | This commit adds the module `FromUnion`, which provides the class method `from_union`. This simplifies the process of selecting data from the result of a UNION, and reduces the likelihood of making mistakes. As a result, instead of this: union = Gitlab::SQL::Union.new([foo, bar]) Foo.from("(#{union.to_sql}) #{Foo.table_name}") We can now write this instead: Foo.from_union([foo, bar]) This commit also includes some changes to make this new setup work properly. For example, a bug in Rails 4 (https://github.com/rails/rails/issues/24193) would break the use of `from("sub-query-here").includes(:relation)` in certain cases. There was also a CI query which appeared to repeat a lot of conditions from an outer query on an inner query, which isn't necessary. Finally, we include a RuboCop cop to ensure developers use this new module, instead of using Gitlab::SQL::Union directly. Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/51307
* Merge branch 'frozen-string-app-finders-graphql' into 'master'Stan Hu2018-09-131-0/+2
|\ | | | | | | | | Enable frozen string in app/graphql + app/finders See merge request gitlab-org/gitlab-ce!21681
| * Enable frozen string in app/graphql + app/findersgfyoung2018-09-111-0/+2
| | | | | | | | Partially addresses #47424.
* | Disable existing offenses for the CodeReuse copsYorick Peterse2018-09-111-0/+10
|/ | | | | This whitelists all existing offenses for the various CodeReuse cops, of which most are triggered by the CodeReuse/ActiveRecord cop.
* [Rails5] Fix snippets_finder arel queriesblackst0ne-rails5-fix-snippets-finderblackst0ne2018-06-141-5/+10
| | | | | | | | | | | There is a bug https://github.com/rails/arel/issues/531 in Rails 5.0 and 5.1 in Arel/ActiveRecord. This commit converts arel based queries to their raw counterparts to make the finder work in Rails 5.0. These changes should be reverted when on Rails 5.2 as since that version such queries work well again. See the bug link.
* Extract method User#authorizations_for_projects.42877-fix-visibility-change-performanceAndreas Brandl2018-03-021-5/+1
|
* Use yield instead of block.call.Andreas Brandl2018-03-021-6/+6
|
* Apply query changes to snippets only.Andreas Brandl2018-03-021-2/+33
| | | | | | | | | | | | | | | | This applies the changes introduced in `Project.public_or_visible_to_user` to the snippets finder only. We know that for `SnippetsFinder`, this change improves SQL timing from 5/23/25s to 0.7/2/4s (mean/p95/p99). At the same time, the scope was too broad, (negatively) affecting SQL timings in various other places: https://gitlab.com/gitlab-com/infrastructure/issues/3772 With this commit, the snippets dashboard stays usuable as we generally don't run into statement timeouts. In contrast to the earlier change in !17088, the scope of the change is limited to `SnippetsFinder` only, thus not affecting other places.
* Revert Project.public_or_visible_to_user changesYorick Peterse2018-03-021-3/+2
| | | | | | | | | | | These changes were introduced in MR https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/17088. In https://gitlab.com/gitlab-com/infrastructure/issues/3772 we discovered these changes lead to a pretty drastic increase in SQL response timings. We'll revert these changes so we can work on a better solution in the mean time without GitLab.com (or other installations) experiecing reduced performance in the mean time.
* Port `read_cross_project` ability from EEBob Van Landuyt2018-02-221-2/+8
|
* Rename use_conditions_only option to use_where_in.42877-snippets-dashboard-slowAndreas Brandl2018-02-201-1/+1
|
* Allow choice between #where or #from.Andreas Brandl2018-02-201-1/+1
| | | | | | | | | | | | Immediately using #from here requires a lot of changes in other finders (e.g. IssuableFinder, TodosFinder). In all places where we use #merge, this goes completely the wrong way when passed in a relation that was built with `#from(...)`: The original query's FROM part gets completely replaced. This avoids changing all other places and focuses on improving SnippetFinder with the downside of two (small) codepaths to do the same thing.
* Remove duplication in Project methods.Andreas Brandl2018-02-201-1/+4
|
* Push feature-related query part up.Andreas Brandl2018-02-201-2/+1
|
* Merge branch ↵Douwe Maan2018-02-091-21/+46
| | | | | | 'security-10-4-25223-snippets-finder-doesnt-obey-feature-visibility' into 'security-10-4' [Port for security-10-4]: Makes SnippetFinder ensure feature visibility
* Fix N+1 query problem for snippets dashboard.40755-snippets-author-n+1Andreas Brandl2018-02-071-1/+1
| | | | Closes #40755.
* Merge branch 'snippets-finder-visibility' into 'security'Douwe Maan2017-05-101-47/+55
| | | | | | Refactor snippets finder & dont return internal snippets for external users See merge request !2094
* Merge branch '19990-update-snippets-page-design' into 'master' Fatih Acet2016-12-121-21/+21
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Resolve "Updated UI for Snippets pages" ## What does this MR do? ## Are there points in the code the reviewer needs to double check? ## Why was this MR needed? ## Screenshots (if relevant) ## Does this MR meet the acceptance criteria? - [ ] [Changelog entry](https://docs.gitlab.com/ce/development/changelog.html) added - [ ] [Documentation created/updated](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/development/doc_styleguide.md) - [ ] API support added - Tests - [ ] Added for this feature/bug - [ ] All builds are passing - [ ] Conform by the [merge request performance guides](http://docs.gitlab.com/ce/development/merge_request_performance_guidelines.html) - [ ] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides) - [ ] Branch has no merge conflicts with `master` (if it does - rebase it please) - [ ] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits) ## What are the relevant issue numbers? Closes #19990 See merge request !7861
| * use Snippet.none in favor of nil to allow chainingMike Greiling2016-12-101-1/+1
| |
| * refactor duplicate code into a by_scope methodMike Greiling2016-12-101-35/+19
| |
| * add scope filters to project snippets pageMike Greiling2016-12-101-4/+20
| |
* | API: Endpoint to expose personal snippets as /snippetsGuyzmo2016-12-011-1/+4
|/ | | | | | | | | | 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>
* Project members with guest role can't access confidential issuesDouglas Barbosa Alexandre2016-06-131-1/+1
|
* Prevent private snippets in public/internal projects from being leaked via APIStan Hu2016-04-251-1/+1
| | | | Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/15580
* Remove `Snippet#expires_at`rs-snippets-dont-expireRobert Speicher2016-03-051-3/+3
| | | | | | This was removed from the interface in https://github.com/gitlabhq/gitlabhq/pull/6027 but its implementation lingered around for two years.
* Rubocop: indentation fixes Yay!!!Dmitriy Zaporozhets2015-02-021-1/+1
|
* internal snippets: fix exposing of titleValery Sizov2014-10-241-0/+2
|
* Admin: user sortingValery Sizov2014-10-131-11/+11
|
* Snippets: public/internal/privateValery Sizov2014-10-091-0/+61