mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2025-12-13 17:56:20 +00:00
feat: include sub groups in report generation
This commit is contained in:
@@ -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
|
||||
*
|
||||
|
||||
@@ -20,7 +20,7 @@ import * as moment from 'moment';
|
||||
import {join} from 'path';
|
||||
import {cwd} from 'process';
|
||||
import {promisify} from 'util';
|
||||
import {flatten2dArray, getProjects, logger} from '../common';
|
||||
import {flatten2dArray, getProjects, getSubGroups, logger} from '../common';
|
||||
import {BOLD_LABELS, GROUPS, LABEL_WEIGHTS} from '../configuration';
|
||||
|
||||
const asyncWriteFile = promisify(writeFile);
|
||||
@@ -295,7 +295,13 @@ export async function getMergeRequestsForProjects(api: Api,
|
||||
export async function report(api: Api, label: string) {
|
||||
const templates = compileTemplates();
|
||||
|
||||
const projects = await getProjects(api, GROUPS);
|
||||
const groupIds: number[] = [];
|
||||
groupIds.push.apply(groupIds, GROUPS);
|
||||
groupIds.push.apply(groupIds, (await getSubGroups(api, GROUPS)).map((group) => group.id));
|
||||
|
||||
logger.log(`Getting data for ${groupIds.length} group(s).`);
|
||||
|
||||
const projects = await getProjects(api, groupIds);
|
||||
const issues = await getIssues(api, label);
|
||||
|
||||
const issuesGroupedByAssignee = groupIssuesByAssignee(issues);
|
||||
|
||||
Reference in New Issue
Block a user