Skip to content
This repository has been archived by the owner on Oct 1, 2019. It is now read-only.

gitlab-explorer won't find some groups if you have a large number of groups that you have access to #11

Open
tneksenoj opened this issue Aug 22, 2019 · 0 comments

Comments

@tneksenoj
Copy link

Describe the bug
We have a gitlab repository with hundreds of groups. Because the gitlab API paginates response the current function "async GetGroupsAsync():Promise<Array>{" won't find some of the groups because it only searches the first few groups returned by the API

To Reproduce
Steps to reproduce the behavior:

  1. Setup your own gilab server.
  2. Create 200+ groups but only give yourself two or 3 parentless groups. The other groups should be subgroups.
  3. Give yourself access two or three of the groups one at the beginning and one at the end.

Expected behavior
Try use git-lab explorer in vscode to find your groups. You will only find the first group.

Desktop (please complete the following information):

  • OS: [e.g.Win
  • VSCode Version [e.g. 1.37.1]
  • GitLab-ce

Additional context
Here is the code that I used to fix this problem.

async GetGroupsAsync():Promise<Array<Group>>{
    let groups:Array<Group> = [];
    let next_groups:Array<Group> = [];
    let p = 1;
    
    try {
        // Need to allow for a large number of groups on the gitlab server. 
        // this searches through the groups page by page and finds those without parents
        let response = await this.httpClient.get('/groups?per_page=20&page='+ p.toString() ); 
        while ( response.data && response.data.length > 0  ) {
                            
            next_groups = response.data.map((group:any)=>{
                return new Group(group);
            }) as Array<Group>;
            next_groups = next_groups.filter((g)=>{return g.GetParentID() === null;}); //Only Root Groups
            groups = groups.concat(next_groups);

            p = p + 1;
            response = await this.httpClient.get('/groups?per_page=20&page='+ p.toString() );
        }   
    } catch (error) {
        this.HandleError(error);
    }
    return groups;            
}
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant