Skip to content

Commit 444de2c

Browse files
committed
Adding 'maxResults' to List Articles
1 parent 387864b commit 444de2c

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

components/trengo/actions/list-articles/list-articles.mjs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ export default {
3939
description: "The article's search term (if not specified, all articles will be returned)",
4040
optional: true,
4141
},
42+
maxResults: {
43+
type: "integer",
44+
label: "Max Results",
45+
description: "Maximum number of articles to return (if not specified, all results will be returned)",
46+
optional: true,
47+
},
4248
},
4349
async run({ $ }) {
4450
const articles = [];
@@ -55,6 +61,9 @@ export default {
5561
});
5662
for await (const item of resourcesStream) {
5763
articles.push(item);
64+
if (this.maxResults && articles.length >= this.maxResults) {
65+
break;
66+
}
5867
}
5968
const length = articles.length;
6069
$.export("$summary", `Successfully retrieved ${length} article${length === 1

0 commit comments

Comments
 (0)