mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
fix(Jira Software Node): Get All Issues operation with Return All hangs (#17825)
This commit is contained in:
@@ -76,6 +76,7 @@ export async function jiraSoftwareCloudApiRequest(
|
||||
}
|
||||
|
||||
export function handlePagination(
|
||||
method: IHttpRequestMethods,
|
||||
body: any,
|
||||
query: IDataObject,
|
||||
paginationType: 'offset' | 'token',
|
||||
@@ -83,10 +84,23 @@ export function handlePagination(
|
||||
): boolean {
|
||||
if (!responseData) {
|
||||
if (paginationType === 'offset') {
|
||||
query.startAt = 0;
|
||||
query.maxResults = 100;
|
||||
if (method === 'GET') {
|
||||
// Example: https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-issue-search/#api-rest-api-2-search-get
|
||||
query.startAt = 0;
|
||||
query.maxResults = 100;
|
||||
} else {
|
||||
// Example: https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-issue-search/#api-rest-api-2-search-post
|
||||
body.startAt = 0;
|
||||
body.maxResults = 100;
|
||||
}
|
||||
} else {
|
||||
body.maxResults = 100;
|
||||
if (method === 'GET') {
|
||||
// Example: https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-issue-search/#api-rest-api-2-search-jql-get
|
||||
query.maxResults = 100;
|
||||
} else {
|
||||
// Example: https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-issue-search/#api-rest-api-2-search-jql-post
|
||||
body.maxResults = 100;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -94,10 +108,20 @@ export function handlePagination(
|
||||
|
||||
if (paginationType === 'offset') {
|
||||
const nextStartAt = (responseData.startAt as number) + (responseData.maxResults as number);
|
||||
query.startAt = nextStartAt;
|
||||
if (method === 'GET') {
|
||||
query.startAt = nextStartAt;
|
||||
} else {
|
||||
body.startAt = nextStartAt;
|
||||
}
|
||||
|
||||
return nextStartAt < responseData.total;
|
||||
} else {
|
||||
body.nextPageToken = responseData.nextPageToken as string;
|
||||
if (method === 'GET') {
|
||||
query.nextPageToken = responseData.nextPageToken as string;
|
||||
} else {
|
||||
body.nextPageToken = responseData.nextPageToken as string;
|
||||
}
|
||||
|
||||
return !!responseData.nextPageToken;
|
||||
}
|
||||
}
|
||||
@@ -114,11 +138,11 @@ export async function jiraSoftwareCloudApiRequestAllItems(
|
||||
const returnData: IDataObject[] = [];
|
||||
|
||||
let responseData;
|
||||
let hasNextPage = handlePagination(body, query, paginationType);
|
||||
let hasNextPage = handlePagination(method, body, query, paginationType);
|
||||
do {
|
||||
responseData = await jiraSoftwareCloudApiRequest.call(this, endpoint, method, body, query);
|
||||
returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]);
|
||||
hasNextPage = handlePagination(body, query, paginationType, responseData);
|
||||
hasNextPage = handlePagination(method, body, query, paginationType, responseData);
|
||||
} while (hasNextPage);
|
||||
|
||||
return returnData;
|
||||
|
||||
Reference in New Issue
Block a user