feat: include sub groups in report generation

This commit is contained in:
Karl-Philipp Wulfert
2019-01-28 16:49:32 +01:00
parent f1fe412734
commit 040c666e74
2 changed files with 21 additions and 3 deletions

View File

@@ -13,7 +13,7 @@
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {Api} from '@openstapps/gitlab-api';
import {Project} from '@openstapps/gitlab-api/lib/types';
import {Group, Project} from '@openstapps/gitlab-api/lib/types';
import {Logger} from '@openstapps/logger';
import {asyncPool} from 'async-pool-native/dist/async-pool';
import {readFile, unlink, writeFile} from 'fs';
@@ -45,6 +45,18 @@ export async function getProjects(api: Api, groups: number[]): Promise<Project[]
return projects;
}
/**
* Get subgroups for a list of groups
*
* @param api GitLab API to make requests with
* @param groups List of groups
*/
export async function getSubGroups(api: Api, groups: number[]): Promise<Group[]> {
return flatten2dArray(await asyncPool(2, groups, async (groupId) => {
return await api.getSubGroupsForGroup(groupId);
}));
}
/**
* Flatten 2d array
*