Commit graph

24 commits

Author SHA1 Message Date
Jacopo
168ff28506 Adds updated_at filter to issues and merge_requests API 2018-03-05 14:10:32 +01:00
Sean McGivern
c2fc40668c Refactor IssuableFinder to extract model-specific logic
By extracting a new `filter_items` method, we can override that in the
IssuesFinder and MergeRequestsFinder separately, so we don't need checks that
the model is the correct one, because we can just use the class we're in to know
that.

We can do the same for the VALID_PARAMS constant, by making it a class method.
2018-02-21 10:31:29 +00:00
Andreas Brandl
95738d4b75 Always eagerly load an issue's author.
Rather radical but avoids n+1 queries in the rather common case we want
to include information about the author.
2018-02-13 18:04:52 +01:00
Jan Provaznik
090ca9c33e Use limit for search count queries
Search query is especially slow if a user searches a generic string
which matches many records, in such case search can take tens of
seconds or time out. To speed up the search query, we search only for
first 1000 records, if there is >1000 matching records we just display
"1000+" instead of precise total count supposing that with such amount
the exact count is not so important for the user.

Because for issues even limited search was not fast enough, 2-phase
approach is used for issues: first we use simpler/faster query to get
all public issues, if this exceeds the limit, we just return the limit.
If the amount of matching results is lower than limit, we re-run more
complex search query (which includes also confidential issues).
Re-running the complex query should be fast enough in such case because the
amount of matching issues is lower than limit.

Because exact total_count is now limited, this patch also switches to
to "prev/next" pagination.

Related #40540
2018-01-23 22:33:42 +01:00
Hiroyuki Sato
cf9c54bd31 Add my_reaction_emoji param to /issues API 2017-09-05 11:56:17 +09:00
Sean McGivern
e7817fc1e0 Remove issuable finder count caching
We're going to cache the total open count separately, and then just perform
these counts on the list. We already do that to get the pagination information,
through Kaminari, and a future change will make Kaminari reuse the query results
from earlier in the request.
2017-08-31 12:21:39 +01:00
Sean McGivern
0e488ef70a Clear issuable counter caches on update
When an issuable's state changes, or one is created, we should clear the cache
counts for a user's assigned issuables, and also the project-wide caches for
this user type.
2017-07-19 10:21:20 +01:00
Sean McGivern
c57ae83dcf Fix issuable state counter cache keys
These cache a hash of counts by state, so the state isn't needed in the key
itself.
2017-07-19 10:21:18 +01:00
Sean McGivern
4e38985b1c Fix typo in IssuesFinder comment
[ci skip]
2017-06-30 15:44:21 +01:00
Sean McGivern
cb30edfae5 Clarify counter caching for users without project access 2017-06-30 10:33:47 +01:00
Sean McGivern
0c6cdd0782 Make finders responsible for counter cache keys 2017-06-30 10:33:46 +01:00
Sean McGivern
c400030d0f Don't count any confidential issues for non-project-members 2017-06-30 10:33:45 +01:00
Sean McGivern
20bb678d91 Cache total issue / MR counts for project by user type
This runs a slightly slower query to get the issue and MR counts in the
navigation, but caches by user type (can see all / none confidential issues) for
two minutes.
2017-06-30 10:33:44 +01:00
Sean McGivern
42ccb5981a Only do complicated confidentiality checks when necessary
When we are filtering by a single project, and the current user has access to
see confidential issues on that project, we don't need to filter by
confidentiality at all - just as if the user were an admin.

The filter by confidentiality often picks a non-optimal query plan: for
instance, AND-ing the results of all issues in the project (a relatively small
set), and all issues in the states requested (a huge set), rather than just
starting small and winnowing further.
2017-06-30 10:33:44 +01:00
Toon Claes
b90f1098cf Add User#full_private_access? to check if user has Private access
In CE only the admin has access to all private groups & projects. In EE also an
auditor can have full private access.

To overcome merge conflicts, or accidental incorrect access rights, abstract
this out in `User#full_private_access?`.

`User#admin?` now only should be used for admin-only features. For private
access-related features `User#full_private_access?` should be used.

Backported from gitlab-org/gitlab-ee!2199
2017-06-23 11:15:35 +02:00
Valery Sizov
387c4b2c21 Backport of multiple_assignees_feature [ci skip] 2017-05-04 17:11:53 +03:00
Joren De Groof
d663b8de24 Fixes milestone/merge_request API endpoint to really scope the results
The MergeRequestsFinder uses the milestone_title instead of the
milestone_id
2017-04-03 18:36:51 +02:00
Jarka Kadlecova
d369acb516 Improve issues filtering performance 2017-03-06 14:45:50 +01:00
mhasbini
7362fd6fdf add a :iids param to IssuableFinder 2017-02-17 20:28:32 +02:00
Sean McGivern
4bf61b8bd4 Merge branch 'jej-24637-move-issue-visible_to_user-to-finder' into 'security'
Issue#visible_to_user moved to IssuesFinder

Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/24637.

See merge request !2039
2016-12-15 11:41:04 -03:00
barthc
418e95bd5f fix issues mr counter 2016-09-20 14:39:15 +01:00
Douglas Barbosa Alexandre
34ee75379c Restrict access to confidential issues 2016-03-17 20:55:38 -03:00
Dmitriy Zaporozhets
20c2e90222
Refactor finders. Prevent circular dependency error
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2014-09-02 15:28:27 +03:00
Dmitriy Zaporozhets
645e8d4705
Move services for collecting items to Finders
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2014-02-25 19:15:08 +02:00