Commit Graph

25 Commits

Author SHA1 Message Date
blackst0ne 53ea0f221e [Rails5] Fix snippets_finder arel queries
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.
2018-06-14 11:20:11 +11:00
Andreas Brandl 39011be53d Extract method User#authorizations_for_projects. 2018-03-02 18:23:03 +01:00
Andreas Brandl 0a3fc7e3c2 Use yield instead of block.call. 2018-03-02 10:15:52 +01:00
Andreas Brandl 82a32e2763 Apply query changes to snippets only.
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.
2018-03-02 09:35:21 +01:00
Yorick Peterse 82ec8eafab Revert Project.public_or_visible_to_user changes
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.
2018-03-02 09:23:05 +01:00
Bob Van Landuyt 148816cd67 Port `read_cross_project` ability from EE 2018-02-22 17:11:36 +01:00
Andreas Brandl 02b9fa0386 Rename use_conditions_only option to use_where_in. 2018-02-20 17:02:11 +01:00
Andreas Brandl c8cafb22bd Allow choice between #where or #from.
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.
2018-02-20 13:08:25 +01:00
Andreas Brandl 86591b8350 Remove duplication in Project methods. 2018-02-20 13:08:25 +01:00
Andreas Brandl 336bc95e36 Push feature-related query part up. 2018-02-20 13:08:24 +01:00
Douwe Maan 5e9e56924a Merge branch 'security-10-4-25223-snippets-finder-doesnt-obey-feature-visibility' into 'security-10-4'
[Port for security-10-4]: Makes SnippetFinder ensure feature visibility
2018-02-09 12:04:05 -06:00
Andreas Brandl f7c30ae30d Fix N+1 query problem for snippets dashboard.
Closes #40755.
2018-02-07 00:22:13 +01:00
Douwe Maan ad309f5d11 Merge branch 'snippets-finder-visibility' into 'security'
Refactor snippets finder & dont return internal snippets for external users

See merge request !2094
2017-05-10 16:48:18 +02:00
Fatih Acet 01b767bd98 Merge branch '19990-update-snippets-page-design' into 'master'
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
2016-12-12 18:06:20 +00:00
Mike Greiling a68735d498 use Snippet.none in favor of nil to allow chaining 2016-12-10 00:57:23 -06:00
Mike Greiling adbc37804e refactor duplicate code into a by_scope method 2016-12-10 00:57:23 -06:00
Mike Greiling 54a1193d79 add scope filters to project snippets page 2016-12-10 00:57:23 -06:00
Guyzmo fde754e267 API: Endpoint to expose personal snippets as /snippets
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>
2016-12-01 19:07:49 +01:00
Douglas Barbosa Alexandre b56c456750 Project members with guest role can't access confidential issues 2016-06-13 19:32:00 -03:00
Stan Hu d5267dfd0d Prevent private snippets in public/internal projects from being leaked via API
Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/15580
2016-04-25 12:02:06 -07:00
Robert Speicher 836d593033 Remove `Snippet#expires_at`
This was removed from the interface in
https://github.com/gitlabhq/gitlabhq/pull/6027 but its implementation
lingered around for two years.
2016-03-05 18:12:17 -05:00
Dmitriy Zaporozhets 61cc6a9244 Rubocop: indentation fixes Yay!!! 2015-02-02 21:59:28 -08:00
Valery Sizov 7f97a1277d internal snippets: fix exposing of title 2014-10-24 19:39:14 +03:00
Valery Sizov 4e0da2325b Admin: user sorting 2014-10-13 16:07:57 +03:00
Valery Sizov 47f539f5a6 Snippets: public/internal/private 2014-10-09 17:09:53 +03:00