Commit b8f67b4d authored by Douwe Maan's avatar Douwe Maan

Merge branch 'dropdown-load-fix' into 'master'

Dropdown loading time preformance fix

## What does this MR do?
Optimizes the performance of the dropdown load time by just sending the required data to load the dropdown instead of the full object

This MR aims to fix #17474 

See merge request !5113
parents d2c9e8ab 22807398
...@@ -2,6 +2,7 @@ Please view this file on the master branch, on stable branches it's out of date. ...@@ -2,6 +2,7 @@ Please view this file on the master branch, on stable branches it's out of date.
v 8.10.0 (unreleased) v 8.10.0 (unreleased)
- Expose {should,force}_remove_source_branch (Ben Boeckel) - Expose {should,force}_remove_source_branch (Ben Boeckel)
- Fix projects dropdown loading performance with a simplified api cal. !5113 (tiagonbotelho)
- Fix commit builds API, return all builds for all pipelines for given commit. !4849 - Fix commit builds API, return all builds for all pipelines for given commit. !4849
- Replace Haml with Hamlit to make view rendering faster. !3666 - Replace Haml with Hamlit to make view rendering faster. !3666
- Expire the branch cache after `git gc` runs - Expire the branch cache after `git gc` runs
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
groupPath: "/api/:version/groups/:id.json" groupPath: "/api/:version/groups/:id.json"
namespacesPath: "/api/:version/namespaces.json" namespacesPath: "/api/:version/namespaces.json"
groupProjectsPath: "/api/:version/groups/:id/projects.json" groupProjectsPath: "/api/:version/groups/:id/projects.json"
projectsPath: "/api/:version/projects.json" projectsPath: "/api/:version/projects.json?simple=true"
labelsPath: "/api/:version/projects/:id/labels" labelsPath: "/api/:version/projects/:id/labels"
licensePath: "/api/:version/licenses/:key" licensePath: "/api/:version/licenses/:key"
gitignorePath: "/api/:version/gitignores/:key" gitignorePath: "/api/:version/gitignores/:key"
......
...@@ -54,6 +54,7 @@ module API ...@@ -54,6 +54,7 @@ module API
class BasicProjectDetails < Grape::Entity class BasicProjectDetails < Grape::Entity
expose :id expose :id
expose :http_url_to_repo, :web_url
expose :name, :name_with_namespace expose :name, :name_with_namespace
expose :path, :path_with_namespace expose :path, :path_with_namespace
end end
......
...@@ -25,8 +25,12 @@ module API ...@@ -25,8 +25,12 @@ module API
@projects = current_user.authorized_projects @projects = current_user.authorized_projects
@projects = filter_projects(@projects) @projects = filter_projects(@projects)
@projects = paginate @projects @projects = paginate @projects
if params[:simple]
present @projects, with: Entities::BasicProjectDetails, user: current_user
else
present @projects, with: Entities::ProjectWithAccess, user: current_user present @projects, with: Entities::ProjectWithAccess, user: current_user
end end
end
# Get an owned projects list for authenticated user # Get an owned projects list for authenticated user
# #
......
...@@ -22,7 +22,7 @@ describe 'Project Title', -> ...@@ -22,7 +22,7 @@ describe 'Project Title', ->
@projects_data = fixture.load('projects.json')[0] @projects_data = fixture.load('projects.json')[0]
spyOn(jQuery, 'ajax').and.callFake (req) => spyOn(jQuery, 'ajax').and.callFake (req) =>
expect(req.url).toBe('/api/v3/projects.json') expect(req.url).toBe('/api/v3/projects.json?simple=true')
d = $.Deferred() d = $.Deferred()
d.resolve @projects_data d.resolve @projects_data
d.promise() d.promise()
......
...@@ -81,6 +81,18 @@ describe API::API, api: true do ...@@ -81,6 +81,18 @@ describe API::API, api: true do
expect(json_response.first.keys).not_to include('open_issues_count') expect(json_response.first.keys).not_to include('open_issues_count')
end end
context 'GET /projects?simple=true' do
it 'returns a simplified version of all the projects' do
expected_keys = ["id", "http_url_to_repo", "web_url", "name", "name_with_namespace", "path", "path_with_namespace"]
get api('/projects?simple=true', user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
expect(json_response.first.keys).to match_array expected_keys
end
end
context 'and using search' do context 'and using search' do
it 'should return searched project' do it 'should return searched project' do
get api('/projects', user), { search: project.name } get api('/projects', user), { search: project.name }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment