Skip to content

Commit

Permalink
perf: query 100 projects instead of 20 (#983)
Browse files Browse the repository at this point in the history
Change the default per_page parameter from 20 to 100 when invoking the GET /projects endpoint from GitLab to prevent unnecessary queries.
  • Loading branch information
lorenzo-cavazzi authored Jul 20, 2020
1 parent 8792363 commit c6fced4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/api-client/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ function addProjectMethods(client) {
};

client.getAllProjects = (extraParams = [],
{ recursive = false, per_page = 20, page = 1, previousResults = [] } = {}
{ recursive = false, per_page = 100, page = 1, previousResults = [] } = {}
) => {
let headers = client.getBasicHeaders();

Expand Down
4 changes: 2 additions & 2 deletions src/project/shared/Projects.state.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ class ProjectsCoordinator {
if (this.model.get("featured.fetching")) return;
// set status to fetching and invoke both APIs
this.model.set("featured.fetching", true);
const promiseStarred = this.client.getProjects({ starred: true, order_by: "last_activity_at" })
const promiseStarred = this.client.getProjects({ starred: true, order_by: "last_activity_at", per_page: 100 })
.then((projectResponse) => {
const projects = projectResponse.data.map((project) => this._starredProjectMetadata(project));
return projects;
})
.catch((error) => {
this.model.set("starredProjects", []);
});
const promiseMember = this.client.getAllProjects({ membership: true, order_by: "last_activity_at" })
const promiseMember = this.client.getAllProjects({ membership: true, order_by: "last_activity_at", per_page: 100 })
.then((projectResponse) => {
const projects = projectResponse.map((project) => this._starredProjectMetadata(project));
return projects;
Expand Down

0 comments on commit c6fced4

Please sign in to comment.