Commit Graph

161 Commits

Author SHA1 Message Date
Sean McGivern 3781cbe0c3 Merge branch 'sh-optimize-todos-api' into 'master'
Significantly reduce N+1 queries in /api/v4/todos endpoint

Closes #40378

See merge request gitlab-org/gitlab-ce!25711
2019-03-07 10:29:04 +00:00
Stan Hu 062efe4f7a Significantly reduce N+1 queries in /api/v4/todos endpoint
By preloading associations and batching issuable metadata lookups,
we can significantly cut the number of SQL queries needed to load
the Todos API endpoint.

On GitLab.com, my own tests showed my user's SQL queries went
from 365 to under 60 SQL queries.

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/40378
2019-03-06 07:03:46 -08:00
Alexandru Croitor be3578d245 Add array support for labels
* Support label parameter as comma separated and array of strings
for merge requests and issues api endpoints
2019-03-06 13:28:42 +02:00
Kamil Trzciński a555a227dd
Merge branch 'filter-confidential-issues' into 'master'
Ability to filter confidential issues

Closes #50747

See merge request gitlab-org/gitlab-ce!24960
2019-02-26 12:24:39 +01:00
Michael Kozono e95b88a06d
Revert "Merge branch 'filter-confidential-issues' into 'master'"
This reverts commit d133bf84c6, reversing
changes made to 7981c0292b.
2019-02-25 12:42:34 -08:00
Robert Schilling bf7846bec0 Only use boolean parameters internally
Use internally only boolean params.
2019-02-22 14:55:07 +01:00
Robert Schilling 73e3a1cd02 Add API support for filtering confidential issues 2019-02-21 14:02:38 +01:00
Sean McGivern cccf611509 Merge branch '55376-related_merge_requests-api-call-returns-merge-requests-that-are-not-related-to-the-issue' into 'master'
Ensure that  related_merge_requests api call returns merge requests in the correct scope

Closes #55376

See merge request gitlab-org/gitlab-ce!25222
2019-02-19 12:05:26 +00:00
Nermin Vehabovic ff671366cb Added: Include order by ID desc for tie breakers in pagination 2019-02-16 11:03:42 +01:00
Robert Schilling 6e4fdc117c Directly use MRs given by ReferencedMergeRequestsService 2019-02-14 23:11:06 +01:00
Robert Schilling feb2cb9085 API: Reference MRs cross-project wise 2019-02-13 23:13:45 +01:00
Sean McGivern 068b41275f Merge branch 'search-title' into 'master'
Add 'in' filter that modifies scope of 'search' filter  to issues and merge requests API

See merge request gitlab-org/gitlab-ce!24350
2019-02-05 09:52:40 +00:00
Hiroyuki Sato 40198f8184 Fix grammar and spelling 2019-02-05 17:32:27 +09:00
Rémy Coutable 3a2abc1d50
Enable the Layout/ExtraSpacing cop
Signed-off-by: Rémy Coutable <remy@rymai.me>
2019-01-24 13:05:45 +01:00
Hiroyuki Sato d32aec06fe Add 'in' filter that modifies scope of 'search' filter to issues and merge requests API 2019-01-14 12:02:55 +09:00
Imre Farkas b1e070bf49
Fix API::Namespaces to accept namepaces with dots
It also renames the API::PROJECT_ENDPOINT_REQUIREMENTS constant to
API::NAMESPACE_OR_PROJECT_REQUIREMENTS
2018-11-28 12:54:11 +01:00
Douwe Maan 34e8d9726d
Expose {closed,merged}_{at,by} in merge requests API index 2018-11-05 13:49:10 +01:00
Helmut Januschka 17a7b41132 add related merge request endpoint 2018-11-01 12:36:01 +01:00
Heinrich Lee Yu d01d1cc8ee Extract EE params in issues API to separate module 2018-10-30 21:37:58 +08:00
Heinrich Lee Yu bf1ed85a9d Refactor api validator to separate class 2018-10-26 10:32:14 +08:00
Heinrich Lee Yu 006631f882 Apply similar change to MRs API 2018-10-26 10:32:14 +08:00
Heinrich Lee Yu 227e30f7fe Issues API: Add None/Any option to assignee_id 2018-10-26 10:32:14 +08:00
gfyoung 3836d69119 Enable frozen string in lib/api and lib/backup
Partially addresses #47424.

Had to make changes to spec files because
stubbing methods on frozen objects is a mess
in RSpec and leads to failures:

https://github.com/rspec/rspec-mocks/issues/1190
2018-09-29 21:04:50 -07:00
Yorick Peterse 2039c8280d
Disable existing offenses for the CodeReuse cops
This whitelists all existing offenses for the various CodeReuse cops, of
which most are triggered by the CodeReuse/ActiveRecord cop.
2018-09-11 17:32:00 +02:00
Sean McGivern aff7dccc1f Use policies to determine if attributes can be set in the API
This is more idiomatic than checking membership explicitly.
2018-08-22 14:17:29 +01:00
Florent Dubois b63ed7cff6 Allow date parameters on Issues and Notes API for group owners
- Allow `created_at` and `updated_at` parameters on Issues API
- Allow `created_at` on Issue Notes API

Closes gitlab-org/gitlab-ce#40059
2018-08-22 12:16:48 +01:00
Jamie Schembri e72388246b Resolve "Allow issue's Internal ID (`iid`) to be set when creating via the API" 2018-08-01 09:03:14 +00:00
Stan Hu cbc20d2b7f Remove N+1 query for author in issues API
This was being masked by the statement cache because only one author was used
per issue in the test..

Also adds support for an Rspec matcher `exceed_all_query_limit`.
2018-06-04 16:39:33 -07:00
Stan Hu ef253a1ee7 Eliminate cached N+1 queries for projects in Issue API
In CE, every `Issue` entity is also a `ProjectEntity`, which calls
`entity&.project.try(:id)` to show the project ID. In an API
request with 100 issues, this would hit the Rails statement cache 100 times
for the same project and cause unnecessary overhead as related models would
also be loaded.

In EE, we call `Issue#supports_weight?` for each issue, which then calls
`project&.feature_available?(:issue_weights)`. If the project is not
preloaded, this incurs additional overhead, as each individual Project
object has to be queried. This can lead to a significant performance hit.
In loading the CE project with 100 issues, this contributed to at least 22%
of the load time.

See https://gitlab.com/gitlab-org/gitlab-ce/issues/47031 for why testing this
is a bit tricky.
2018-05-31 00:18:05 -07:00
Rémy Coutable 7381a33f69 Merge branch '44799-api-naming-issue-scope' into 'master'
Resolve "API naming for issue scope"

Closes #44799

See merge request gitlab-org/gitlab-ce!18935
2018-05-21 08:56:42 +00:00
Mark Chao d839b880a2 Add created_by_me and assigned_to_me scopes
Deprecate corresponding dash versions created-by-me and assigned-to-me
2018-05-21 09:55:30 +08:00
haseeb 789eb36c84 Remove authentication for readonly endpoints in issues API 2018-05-15 14:41:33 +00:00
🙈 jacopo beschi 🙉 c6b1043e9d Resolve "Make a Rubocop that forbids returning from a block" 2018-04-18 09:19:40 +00:00
Felipe Artur b9dfd071ed Include subgroup issues when searching for group issues using the API 2018-04-05 17:19:52 -03:00
Jacopo 168ff28506 Adds updated_at filter to issues and merge_requests API 2018-03-05 14:10:32 +01:00
Yorick Peterse cca61980d5
Track and act upon the number of executed queries
This ensures that we have more visibility in the number of SQL queries
that are executed in web requests. The current threshold is hardcoded to
100 as we will rarely (maybe once or twice) change it.

In production and development we use Sentry if enabled, in the test
environment we raise an error. This feature is also only enabled in
production/staging when running on GitLab.com as it's not very useful to
other users.
2018-02-01 17:00:46 +01:00
🙈 jacopo beschi 🙉 729f05f0e3 Adds Rubocop rule for line break around conditionals 2018-01-11 16:34:01 +00:00
Brent Greeff 34b9cc9674 API: get participants from merge_requests & issues 2018-01-05 15:21:53 +00:00
Mark Fletcher c9732b3c6d Employ declared_params in finder methods for MR and Issue API lists
- Ensure that unwanted params are no passed to actual finder classes
2017-12-20 07:23:57 +00:00
Sean McGivern c59ae54705 Merge branch 'issue_30663' into 'security-10-2'
Prevent creating issues through API without having permissions

See merge request gitlab/gitlabhq!2225

(cherry picked from commit c298bbaa88883343dc9cbbb6abec0808fb3b546c)

915b97c5 Prevent creating issues through API without having permissions
2017-12-08 13:48:18 -08:00
George Andrinopoulos 7fb1bb01bd Create issue and merge request destroy services 2017-11-25 22:09:18 +02:00
Sean McGivern 4d4ddb6004 Fail when issuable_meta_data is called on an unlimited collection
This method can be called with an array, or a relation:

1. Arrays always have a limited amount of values, so that's fine.
2. If the relation does not have a limit value applied, then we will load every
   single object in that collection, and prevent N+1 queries for the metadata
   for that. But that's wrong, because we should never call this without an
   explicit limit set. So we raise in that case, and this commit will see which
   specs fail.

The only failing specs here were the issues API specs, and the specs for
IssuableMetadata itself, and both have been addressed.
2017-11-07 16:26:55 +00:00
Jarka Kadlecova 994e7d1359 Create system notes for MR too, improve doc + clean up code 2017-09-14 14:50:32 +02:00
Jarka Kadlecova 073ba05d31 Support discussion lock in the API 2017-09-14 14:50:32 +02:00
Hiroyuki Sato cf9c54bd31 Add my_reaction_emoji param to /issues API 2017-09-05 11:56:17 +09:00
Robert Schilling 6a2ee0968e API: Use defined project requirements 2017-08-31 14:57:47 +02:00
Robert Speicher 966b635221 Merge branch '28453-add-time-estimate-time-spent-to-api-issue-output' into 'master'
Add time stats to Issue and Merge Request API

Closes #28453

See merge request !13335
2017-08-30 17:35:14 +00:00
Travis Miller 749c389345 Add time stats to issue and merge request API end points 2017-08-29 08:31:36 -05:00
Travis Miller ce1ce82045 Resolve new N+1 by adding preloads and metadata to issues end points 2017-08-29 08:31:36 -05:00
Robert Schilling e80313f9ee Conditionally destroy a ressource 2017-08-28 16:40:25 +02:00