Commit Graph

126 Commits

Author SHA1 Message Date
Felipe Artur 0ae48e0687 Move issue related_branches to service
Moves the related_branches method from Issue model
to RelatedBranchesService
2018-10-04 15:59:14 -03:00
Jarka Košanová 3a7c29417d Add specs for closing and reopening issue 2018-09-24 22:50:17 +02:00
Sean McGivern c73da6c1e7 Move Issue#{referenced,closed_by}_merge_requests to service
These methods don't really need to be on the Issue model. Issue#related_branches
can also be moved to a service, but we can do that in a separate commit.

This commit does not change any behaviour; it just moves code around, renames
the service, and refactors the specs.
2018-08-21 12:40:44 +01:00
Mark Chao a63bce1a4b Resolve "Rename the `Master` role to `Maintainer`" Backend 2018-07-11 14:36:08 +00:00
Shinya Maeda 82a49d0fea Clarify scope for AtomicInternalId shared spec 2018-05-14 17:41:56 +09:00
Jacopo 5a29a304be Shows new branch/mr button even when branch exists 2018-04-19 13:56:36 +02:00
Andreas Brandl 6568b4a98e Add shared specs for AtomicInternalId concern. 2018-03-16 13:35:26 +01:00
Bob Van Landuyt 148816cd67 Port `read_cross_project` ability from EE 2018-02-22 17:11:36 +01:00
Yorick Peterse d0b8f536a1
Remove soft removals related code
This removes all usage of soft removals except for the "pending delete"
system implemented for projects. This in turn simplifies all the query
plans of the models that used soft removals. Since we don't really use
soft removals for anything useful there's no point in keeping it around.

This _does_ mean that hard removals of issues (which only admins can do
if I'm not mistaken) can influence the "iid" values, but that code is
broken to begin with. More on this (and how to fix it) can be found in
https://gitlab.com/gitlab-org/gitlab-ce/issues/31114.

Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/37447
2018-01-08 17:04:45 +01:00
Oswaldo Ferreira bf8c20729b Cache merged and closed events data in merge_request_metrics table 2018-01-02 17:45:25 -02:00
blackst0ne 27c95364b5 Replace '.team << [user, role]' with 'add_role(user)' in specs 2017-12-22 19:18:28 +11:00
Yorick Peterse 856447ccd3
Throttle the number of UPDATEs triggered by touch
This throttles the number of UPDATE queries that can be triggered by
calling "touch" on a Note, Issue, or MergeRequest. For Note objects we
also take care of updating the associated "noteable" relation in a
smarter way than Rails does by default.
2017-12-06 15:59:37 +01:00
George Andrinopoulos 3963f91ee3 Move update_project_counter_caches? out of issue and merge request 2017-11-11 21:06:28 +02:00
Rémy Coutable f070265a6d
Introduce new hook data builders for Issue and MergeRequest
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-10-09 16:44:47 +02:00
Rémy Coutable 075d651604 Start adding Gitlab::HookData::IssuableBuilder
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-10-09 15:07:10 +02:00
Yorick Peterse c158a22fd3
Only update the sidebar count caches when needed
This ensures the issues/MR cache of the sidebar is only updated when the
state or confidential flags changes, instead of changing this for every
update.
2017-08-30 15:49:40 +02:00
Yorick Peterse 6ec53f5d48
Cache the number of open issues and merge requests
Every project page displays a navigation menu that in turn displays the
number of open issues and merge requests. This means that for every
project page we run two COUNT(*) queries, each taking up roughly 30
milliseconds on GitLab.com. By caching these numbers and refreshing them
whenever necessary we can reduce loading times of all these pages by up
to roughly 60 milliseconds.

The number of open issues does not include confidential issues. This is
a trade-off to keep the code simple and to ensure refreshing the data
only needs 2 COUNT(*) queries instead of 3. A downside is that if a
project only has 5 confidential issues the counter will be set to 0.

Because we now have 3 similar counting service classes the code
previously used in Projects::ForksCountService has mostly been moved to
Projects::CountService, which in turn is reused by the various service
classes.

Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/36622
2017-08-23 13:42:29 +02:00
Rémy Coutable 1b413bd62f Enable Timecop safe mode
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-08-11 14:53:17 +02:00
Rémy Coutable c946ee1282
Enable the Layout/SpaceBeforeBlockBraces cop
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-08-09 11:52:22 +02:00
Sean McGivern c94990820a Merge branch '32844-issuables-performance' into 'master'
Issuables: Move some code from create services to Sidekiq workers

See merge request !13326
2017-08-07 21:21:29 +00:00
Jarka Kadlecova 9ef3c431e4 Move some after_create parts to worker to improve performance 2017-08-07 15:57:56 +02:00
Robert Speicher 72a7b30c9f Change all `:empty_project` to `:project` 2017-08-02 17:47:31 -04:00
Robert Speicher 9513bd18c4 Ensure all project factories use `:repository` trait or `:empty_project` 2017-08-01 14:51:52 -04:00
Rémy Coutable ddccd24c13 Remove superfluous lib: true, type: redis, service: true, models: true, services: true, no_db: true, api: true
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-07-27 14:31:53 +02:00
Grzegorz Bizon 0430b76441 Enable Style/DotPosition Rubocop 👮 2017-06-21 13:48:12 +00:00
Robert Speicher a6ec5121f0 Correct RSpec/SingleLineHook cop offenses 2017-06-14 13:18:56 -05:00
Valery Sizov e2a3a5095a Move update_assignee_cache_counts to the service 2017-05-12 14:12:29 +03:00
Valery Sizov 387c4b2c21 Backport of multiple_assignees_feature [ci skip] 2017-05-04 17:11:53 +03:00
Alfredo Sumaran b64a37c4ed Allow to create new branch and empty WIP merge request from issue page 2017-05-04 08:09:21 +00:00
Valery Sizov 36a8cc3eca Remove helpers assigned_issuables_count and cached_assigned_issuables_count 2017-04-20 13:28:04 +03:00
Robert Speicher add1c18860 Remove an unused `Issue.open_for` scope 2017-04-10 18:32:30 -04:00
Felipe Artur 251255e7ca Do not set closed_at to nil when issue is reopened 2017-04-04 15:19:09 -03:00
Oswaldo Ferreira d730b69eb2 Spam check only when spammable attributes have changed 2017-03-21 14:20:15 -03:00
Felipe Artur 94c19fbfe8 Add closed_at field to issues 2017-03-17 16:41:09 -03:00
Douwe Maan b7123a8f59 Merge branch '27271-missing-time-spent-in-issue-webhook' into 'master'
Include time tracking attributes in webhooks payload

Closes #27271

See merge request !9942
2017-03-15 15:29:16 +00:00
Ruben Davila dd53a9c013 Include time tracking attributes in webhooks payload 2017-03-14 11:56:15 -05:00
Valery Sizov 29e34c3326 Preserve order by priority on issues board 2017-03-14 18:13:52 +02:00
Oswaldo Ferreira aeb9db6753 Present group and dashboard MR list without grouping by project 2017-01-27 20:20:18 -02:00
Berna Castro ac66268443 Refactor Project#to_reference and make full_path a keyword argument
Refactor overall code and fix failing specs

Fix Project#to_reference

Fix wrong spaces and update changelog

Refactor #to_reference for Project & Issue

Fix and improves Project#to_reference
2017-01-27 20:20:17 -02:00
Berna Castro 78c8bce1ff Fix and add specs for Issue#to_reference 2017-01-27 20:20:17 -02:00
Robert Speicher fcb37542e7 Use `:empty_project` where possible in model specs 2017-01-26 17:44:59 -05:00
Robert Speicher c1743ba4c4 Use a project factory with a repository where necessary 2017-01-25 14:52:12 -05:00
James Lopez 112f470572 Fix cross-project references copy to include the project reference
Also added relevant specs and refactored to_references in a bunch of places to be more consistent.
2017-01-03 13:01:46 +01: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
Oswaldo Ferreira f272ee6eba Add shorthand support to gitlab markdown references 2016-12-02 19:18:17 -02:00
Ahmad Sherif 916332815e Drop Project#authorized_for_user? in favor of ProjectTeam#member?
Closes #23938
2016-11-23 12:57:58 +02:00
Douwe Maan bf061d0aff
Merge branch 'issue_23548_dev' into 'master'
disable markdown in comments when referencing disabled features

fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/23548

This MR prevents the following references when tool is disabled:

- issues
- snippets
- commits - when repo is disabled
- commit range - when repo is disabled
- milestones

This MR does not prevent references to repository files, since they are just markdown links and don't leak
information.

See merge request !2011

Signed-off-by: Rémy Coutable <remy@rymai.me>
2016-11-09 12:25:17 +01:00
Paco Guzman 493367108e Use MergeRequestsClosingIssues cache data on Issue#closed_by_merge_requests method 2016-10-20 12:55:14 +02:00
Rémy Coutable ec0061a95c Allow Member.add_user to handle access requesters
Changes include:

- Ensure Member.add_user is not called directly when not necessary
- New GroupMember.add_users_to_group to have the same abstraction level as for Project
- Refactor Member.add_user to take a source instead of an array of members
- Fix Rubocop offenses
- Always use Project#add_user instead of project.team.add_user
- Factorize users addition as members in Member.add_users_to_source
- Make access_level a keyword argument in GroupMember.add_users_to_group and ProjectMember.add_users_to_projects
- Destroy any requester before adding them as a member
- Improve the way we handle access requesters in Member.add_user
  Instead of removing the requester and creating a new member,
  we now simply accepts their access request. This way, they will
  receive a "access request granted" email.
- Fix error that was previously silently ignored
- Stop raising when access level is invalid in Member, let Rails validation do their work

Signed-off-by: Rémy Coutable <remy@rymai.me>
2016-09-28 09:43:00 +02:00
Yorick Peterse 002ad21581
Method for returning issues readable by a user
The method Ability.issues_readable_by_user takes a list of users and an
optional user and returns an Array of issues readable by said user. This
method in turn is used by
Banzai::ReferenceParser::IssueParser#nodes_visible_to_user so this
method no longer needs to get all the available abilities just to check
if a user has the "read_issue" ability.

To test this I benchmarked an issue with 222 comments on my development
environment. Using these changes the time spent in nodes_visible_to_user
was reduced from around 120 ms to around 40 ms.
2016-07-29 12:51:18 +02:00