Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fetching more than 200 Azure DevOps issues #10073

Merged
merged 1 commit into from
Aug 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 16 additions & 14 deletions packages/server/utils/AzureDevOpsServerManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -425,21 +425,23 @@ class AzureDevOpsServerManager implements TaskIntegrationManager {
const workItems = [] as WorkItem[]
let firstError: Error | undefined
const uri = `https://${instanceId}/_apis/wit/workitemsbatch?api-version=7.1-preview.1`
const payload = !!fields
? {ids: workItemIds, fields: fields}
: {ids: workItemIds, $expand: 'Links'}
const res = await this.post<WorkItemBatchResponse>(uri, payload)
if (res instanceof Error) {
if (!firstError) {
firstError = res
}
} else {
const mappedWorkItems = (res.value as WorkItem[]).map((workItem) => {
return {
...workItem
// we can fetch at most 200 items at once VS403474
for (let i = 0; i < workItemIds.length; i += 200) {
const ids = workItemIds.slice(i, i + 200)
const payload = !!fields ? {ids, fields: fields} : {ids, $expand: 'Links'}
Dschoordsch marked this conversation as resolved.
Show resolved Hide resolved
const res = await this.post<WorkItemBatchResponse>(uri, payload)
if (res instanceof Error) {
if (!firstError) {
firstError = res
}
})
workItems.push(...mappedWorkItems)
} else {
const mappedWorkItems = (res.value as WorkItem[]).map((workItem) => {
return {
...workItem
}
})
workItems.push(...mappedWorkItems)
}
Dschoordsch marked this conversation as resolved.
Show resolved Hide resolved
}
return {error: firstError, workItems: workItems}
}
Expand Down
Loading