Commit Graph
66 Commits
Author SHA1 Message Date
Yorick Peterse d6a8021ea1 Scope issue projects to a Group when possible
When using IssuableFinder with a Group we can greatly reduce the amount
of projects operated on (due to not including all public/internal
projects) by simply passing it down to the ProjectsFinder class.

This reduces the timings of the involved queries from roughly 300
ms to roughly 20 ms.

Fixes gitlab-org/gitlab-ce#4071, gitlab-org/gitlab-ce#3707
2016-01-18 12:27:33 +01:00
Yorick Peterse fc443ea7bc Drop projects order in IssuableFinder
When grabbing the projects to filter issues by we don't care about the
order they're returned in. By removing the ORDER BY the resulting query
can be quite a bit faster.
2016-01-07 14:53:02 +01:00
Valery Sizov 8b18449125 remove public field from namespace and refactoring 2016-01-04 16:00:29 +02:00
Greg Smethells dbbd2b863b sort milestones by due_date 2015-12-03 08:53:34 -06:00
Yorick Peterse fed059a12d Port GitLab EE ProjectsFinder changes
These changes were added in GitLab EE commit
d39de0ea91. The tests were a bit bugged
(they used a non existing group, thus not testing a crucial part) which
I only noticed when porting CE changes to EE.
2015-11-20 15:53:04 +01:00
Dmitriy Zaporozhets 68d4ab2381 Merge branch 'emoji_votes' into 'master'
Award Emoji

This it first iteration of award emoji feature.
We have plan to extend emoji picker by the next release.

For now, you can add award by clicking to the emoji picker or posting a regular comment with emoji like "👍" and any other. You can post not only emoji that listed in the emoji picker.

See merge request !1825
2015-11-19 21:34:38 +00:00
Yorick Peterse 8591cc02be Use a JOIN in IssuableFinder#by_project
When using IssuableFinder/IssuesFinder to find issues for multiple
projects it's more efficient to use a JOIN + a "WHERE project_id IN"
condition opposed to running a sub-query.

This change means that when finding issues without labels we're now
using the following SQL:

    SELECT issues.*
    FROM issues
    JOIN projects ON projects.id = issues.project_id

    LEFT JOIN label_links ON label_links.target_type = 'Issue'
                          AND label_links.target_id  = issues.id

    WHERE (
        projects.id IN (...)
        OR projects.visibility_level IN (20, 10)
    )
    AND issues.state IN ('opened','reopened')
    AND label_links.id IS NULL
    ORDER BY issues.id DESC;

instead of:

    SELECT issues.*
    FROM issues
    LEFT JOIN label_links ON label_links.target_type = 'Issue'
                          AND label_links.target_id  = issues.id

    WHERE issues.project_id IN (
        SELECT id
        FROM projects
        WHERE id IN (...)
        OR visibility_level IN (20,10)
    )
    AND issues.state IN ('opened','reopened')
    AND label_links.id IS NULL
    ORDER BY issues.id DESC;

The big benefit here is that in the last case PostgreSQL can't properly
use all available indexes. In particular it ends up performing a
sequence scan on the "label_links" table (processing around 290 000
rows). The new query is roughly 2x as fast as the old query.
2015-11-19 11:58:05 +01:00
Yorick Peterse e9cd58f5d5 Memoize IssuableFinder#projects
Since this method's returned data doesn't change between calls on the
same IssuableFinder instance we can just memoize this similar to the
"project" method.
2015-11-19 11:48:50 +01:00
Yorick Peterse c232a0f97f Removed trailing whitespace from IssuableFinder 2015-11-19 11:48:50 +01:00
Valery Sizov 06a4fd1035 css improvements 2015-11-19 01:25:59 +02:00
Yorick Peterse f486b06c4d Return internal projects in PersonalProjectsFinder
When getting the projects of a user we should get the public _and_
internal projects, not just the public ones.
2015-11-18 15:08:28 +01:00
Yorick Peterse fbcf3bd3fc Refactor ProjectsFinder to not pluck IDs
This class now uses a UNION (when needed) instead of plucking tens of
thousands of project IDs into memory. The tests have also been
re-written to ensure all different use cases are tested properly
(assuming I didn't forget any cases).

The finder has also been broken up into 3 different finder classes:

* ContributedProjectsFinder: class for getting the projects a user
  contributed to.
* PersonalProjectsFinder: class for getting the personal projects of a
  user.
* ProjectsFinder: class for getting generic projects visible to a given
  user.

Previously a lot of the logic of these finders was handled directly in
the users controller.
2015-11-18 13:05:45 +01:00
Yorick Peterse 2110247f83 Refactoed GroupsFinder into two separate classes
In the previous setup the GroupsFinder class had two distinct tasks:

1. Finding the projects user A could see
2. Finding the projects of user A that user B could see

Task two was actually handled outside of the GroupsFinder (in the
UsersController) by restricting the returned list of groups to those the
viewed user was a member of. Moving all this logic into a single finder
proved to be far too complex and confusing, hence there are now two
finders:

* GroupsFinder: for finding groups a user can see
* JoinedGroupsFinder: for finding groups that user A is a member of,
  restricted to either public groups or groups user B can also see.
2015-11-18 13:05:45 +01:00
Dmitriy Zaporozhets 8a03cb8744 Lets add more tests to Milestones services
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2015-11-16 14:39:19 +01:00
Dmitriy Zaporozhets 986695e136 Refactor global and group milestones logic
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2015-11-16 14:07:38 +01:00
Valery Sizov 6051c28fc0 Allow groups to appear in the search results if the group owner allows it 2015-11-05 13:18:51 +02:00
Douwe Maan 8b8fbd4e7f Rename confusing methods 2015-10-19 11:46:22 +02:00
Douwe Maan 0108cdf495 Improve performance of filtering issues by milestone 2015-10-16 11:43:26 +02:00
Zeger-Jan van de Weg 9127ae5ca8 Improve performance of queries
Credits to Douwe Maan
2015-10-16 11:30:26 +02:00
Zeger-Jan van de Weg ac44e3844d Add project scope to milestone search 2015-10-16 11:30:26 +02:00
Dmitriy Zaporozhets 69bcef32e1 Merge remote-tracking branch 'public/trending-projects-performance' 2015-10-08 16:22:43 +02:00
Stan Hu dfbbc80611 Support filtering by "Any" milestone or issue and fix "No Milestone" and "No Label" filters
Closes #2619

Closes https://github.com/gitlabhq/gitlabhq/issues/9631
2015-10-07 07:21:50 -07:00
Yorick Peterse b7abba0ca0 Revamp trending projects query
This changes the query to use a COUNT nested in an INNER JOIN, instead
of a COUNT plus a GROUP BY. There are two reasons for this:

1. Using a COUNT in an INNER JOIN can be quite a bit faster.
2. The use of a GROUP BY means that method calls such as "any?"
   (and everything else that calls "count") operate on a Hash that
   counts the amount of notes on a per project basis, instead of just
   counting the total amount of projects.

The query has been moved into Project.trending as its logic is simple
enough. As a result of this testing the TrendingProjectsFinder class
simply involves testing if the right methods are called, removing the
need for setting up database records.
2015-10-06 17:26:32 +02:00
Yorick Peterse d15eec6460 Use >= instead of > in TrendingProjectsFinder
By using >= we can ensure we actually get all comments of the past
month, instead of the comments of the past month minus the first day in
the range.
2015-10-06 17:26:32 +02:00
Guilherme Garnier 2b075f16c7 Fix rubocop warnings in app 2015-10-03 00:56:37 -05:00
Dmitriy Zaporozhets b6de7ad49e Fix 500 on trending projects if isntance has 100k+ projects
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2015-09-18 10:45:42 +02:00
Dmitriy Zaporozhets c27c813311 Improve trending projects finder
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2015-08-26 22:43:04 +02:00
Robert Speicher d00cb00d6b Rename NoMilestone to Milestone::None
Also refactors IssuableFinder to avoid redundant title check.
2015-07-06 22:39:55 -04:00
Robert Speicher 3ee3cb24d4 Allow user to filter by Issues/Merge Requests without a Milestone 2015-07-06 22:39:55 -04:00
Dmitriy Zaporozhets 7524d7c082 Revert merge request states renaming
Replaced:
* "Accepted" with "Merged"
* "Rejected" with "Closed"

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2015-06-19 17:09:50 +02:00
Douwe Maan 45e4727f97 Set milestone on new issue when creating issue from index with milestone filter active. 2015-05-27 14:22:11 +02:00
Douwe Maan d25026a512 Add Accepted and Rejected tabs to MR lists. 2015-05-25 17:01:27 +02:00
Dominik Sander e6ee8d0ebe Group milestones by title in the dashboard and all other issue views
This groups milestones by title for issue views like it has been done for
the milestone dashboard/project overview. Before milestones with the
same title would show up multiple times in the filter dropdown and one could
only filter per project and milestone. Now the milestone filter is based
on the title of the milestone, i.e. all issues marked with the same
milestone title are shown.
2015-05-01 01:12:58 +02:00
Dmitriy Zaporozhets c1c93f4f7a Fix tests and unassigned filter for issues. Updated CHANGELOG 2015-03-27 00:27:51 -07:00
Dmitriy Zaporozhets dfb4fcb685 No magic numbers for issues filtering 2015-03-26 18:56:42 -07:00
Dmitriy Zaporozhets 7faae7c163 Merge pull request #8092 from cirosantilli/factor-finder-perms
Factor permission check in issuable finder
2015-03-02 15:24:59 -08:00
Dmitriy Zaporozhets 3c2139ed17 Fix trending projects ordering 2015-02-18 22:23:24 -08:00
Dmitriy Zaporozhets 3e97ac2022 Add index on order columns 2015-02-06 10:21:48 -08:00
Dmitriy Zaporozhets 8952fc015f Apply default scope to labels and remove one for notes 2015-02-05 20:29:41 -08:00
Dmitriy Zaporozhets 61cc6a9244 Rubocop: indentation fixes Yay!!! 2015-02-02 21:59:28 -08:00
Dmitriy Zaporozhets 368e9a0862 Rubocop: Style/CaseIndentation enabled 2015-02-02 21:26:40 -08:00
Ciro Santilli d37cf2a23d Factor permission check in issuable finder 2015-01-01 21:11:38 +01:00
Dmitriy Zaporozhets e0f30c605b Add author filter for issues & merge requests pages
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2014-12-05 17:13:07 +02:00
Dmitriy Zaporozhets 9306d8fca2 Merge branch 'dashboard_issues_and_mr' into 'master'
Dashboard issues and merge request filters

Fixes #1597

See merge request !1219
2014-10-28 13:38:41 +00:00
Marin Jankovski d3bdd3ba67 Do not filter out issues and merge requests related to user right away. 2014-10-27 10:02:20 +01: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
Ciro Santilli 7984065776 Improve formatting of app/finders/README.md 2014-10-07 22:39:45 +02:00
Dmitriy Zaporozhets 4f1bb91a75 Fix finder and tests for new membership models
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2014-09-15 16:45:28 +03:00