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(Linear Node): Fix issue with data not always being returned #9273

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 15 additions & 5 deletions packages/nodes-base/nodes/Linear/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,30 @@ export function capitalizeFirstLetter(data: string) {
export async function linearApiRequestAllItems(
this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions,
propertyName: string,

body: any = {},
limit?: number,
): Promise<any> {
const returnData: IDataObject[] = [];

let responseData;
body.variables.first = 50;
body.variables.first = limit && limit < 50 ? limit : 50;
body.variables.after = null;

const propertyPath = propertyName.split('.');
const nodesPath = [...propertyPath, 'nodes'];
const endCursorPath = [...propertyPath, 'pageInfo', 'endCursor'];
const hasNextPagePath = [...propertyPath, 'pageInfo', 'hasNextPage'];

do {
responseData = await linearApiRequest.call(this, body);
returnData.push.apply(returnData, get(responseData, [propertyName, 'nodes']) as IDataObject[]);
body.variables.after = get(responseData, [propertyName, 'pageInfo', 'endCursor']);
} while (get(responseData, [propertyName, 'pageInfo', 'hasNextPage']));
const nodes = get(responseData, nodesPath) as IDataObject[];
returnData.push(...nodes);
body.variables.after = get(responseData, endCursorPath);
if (limit && returnData.length >= limit) {
return returnData;
}
} while (get(responseData, hasNextPagePath));

return returnData;
}

Expand Down
1 change: 0 additions & 1 deletion packages/nodes-base/nodes/Linear/IssueDescription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ export const issueFields: INodeProperties[] = [
default: 50,
typeOptions: {
minValue: 1,
maxValue: 300,
},
displayOptions: {
show: {
Expand Down
4 changes: 1 addition & 3 deletions packages/nodes-base/nodes/Linear/Linear.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,7 @@ export class Linear implements INodeType {
responseData = await linearApiRequestAllItems.call(this, 'data.issues', body);
} else {
const limit = this.getNodeParameter('limit', 0);
body.variables.first = limit;
responseData = await linearApiRequest.call(this, body);
responseData = responseData.data.issues.nodes;
responseData = await linearApiRequestAllItems.call(this, 'data.issues', body, limit);
}
}
if (operation === 'update') {
Expand Down