mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-20 00:23:03 +00:00
refactor: adjust code to updated dependencies
This commit is contained in:
@@ -18,8 +18,16 @@ import {Group, Project} from '@openstapps/gitlab-api/lib/types';
|
||||
import {Logger} from '@openstapps/logger';
|
||||
import {readFile, writeFile} from 'fs';
|
||||
import {promisify} from 'util';
|
||||
import {CONCURRENCY} from './configuration';
|
||||
|
||||
/**
|
||||
* Promisified version of readFile
|
||||
*/
|
||||
export const readFilePromisified = promisify(readFile);
|
||||
|
||||
/**
|
||||
* Promisified version of writeFile
|
||||
*/
|
||||
export const writeFilePromisified = promisify(writeFile);
|
||||
|
||||
/**
|
||||
@@ -29,15 +37,15 @@ export const writeFilePromisified = promisify(writeFile);
|
||||
* @param groups List of groups
|
||||
*/
|
||||
export async function getProjects(api: Api, groups: number[]): Promise<Project[]> {
|
||||
Logger.info('Fetching all projects for specified groups (' + groups.length + ')...');
|
||||
Logger.info(`Fetching all projects for specified groups (${groups.length})...`);
|
||||
|
||||
const projectResults = await asyncPool(3, groups, (groupId) => {
|
||||
const projectResults = await asyncPool(CONCURRENCY, groups, async (groupId) => {
|
||||
return api.getProjectsForGroup(groupId);
|
||||
});
|
||||
|
||||
const projects = flatten2dArray(projectResults);
|
||||
|
||||
Logger.log('Fetched ' + projects.length + ' project(s).');
|
||||
Logger.log(`Fetched ${projects.length} project(s).`);
|
||||
|
||||
return projects;
|
||||
}
|
||||
@@ -49,8 +57,8 @@ export async function getProjects(api: Api, groups: number[]): Promise<Project[]
|
||||
* @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);
|
||||
return flatten2dArray(await asyncPool(CONCURRENCY, groups, async (groupId) => {
|
||||
return api.getSubGroupsForGroup(groupId);
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user