in src/service/helper.ts [154:184]
async getWorkItemsBatch(id: string, ids: number[], connections: { [key: string]: WorkItemLink[] }, clientOptions?: IVssRestClientOptions): Promise<Map<string, TeamDictionaryValue>> {
let batch = [];
if (ids.length > 200) {
let index = 0, chunk = 0, length = ids.length;
while (index < length) {
batch[chunk++] = ids.slice(index, (index += 200));
}
} else {
batch = [ids]
}
const workItemsClient = getClient(WorkItemTrackingRestClient, clientOptions);
let map = (await Promise.all(batch.map(it => workItemsClient.getWorkItemsBatch({
$expand: WorkItemExpand.All,
asOf: new Date(),
errorPolicy: WorkItemErrorPolicy.Omit,
fields: [],
ids: it
}).then(data => new Map(data.map(item => [`${item.id}`, item]))).handle(new Map<string, WorkItem>(), "Error fetch items batch!")))
).reduce((acc, next) => {
next.forEach((value, key) => {
if (!acc.has(key)) {
acc.set(key, value);
}
});
return acc;
}, new Map<string, WorkItem>())
return Promise.resolve(new Map<string, TeamDictionaryValue>([[id, { connections, map }]]));
},