Skip to content

Commit 1f311f7

Browse files
authored
Gong "New Call" trigger update pagination (#18979)
* updates * pnpm-lock.yaml * pnpm-lock.yaml * update * versions
1 parent b32ca36 commit 1f311f7

File tree

8 files changed

+40
-16
lines changed

8 files changed

+40
-16
lines changed

components/gong/actions/add-new-call/add-new-call.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default {
88
name: "Add New Call",
99
description: "Add a new call. [See the documentation](https://us-66463.app.gong.io/settings/api/documentation#post-/v2/calls)",
1010
type: "action",
11-
version: "0.0.4",
11+
version: "0.0.5",
1212
annotations: {
1313
destructiveHint: false,
1414
openWorldHint: true,

components/gong/actions/get-extensive-data/get-extensive-data.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default {
77
key: "gong-get-extensive-data",
88
name: "Get Extensive Data",
99
description: "Lists detailed call data. [See the documentation](https://gong.app.gong.io/settings/api/documentation#post-/v2/calls/extensive)",
10-
version: "0.0.4",
10+
version: "0.0.5",
1111
annotations: {
1212
destructiveHint: false,
1313
openWorldHint: true,

components/gong/actions/list-calls/list-calls.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
name: "List calls",
66
description: "List calls. [See the documentation](https://us-66463.app.gong.io/settings/api/documentation#get-/v2/calls)",
77
type: "action",
8-
version: "0.0.5",
8+
version: "0.0.6",
99
annotations: {
1010
destructiveHint: false,
1111
openWorldHint: true,

components/gong/actions/retrieve-transcripts-of-calls/retrieve-transcripts-of-calls.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
name: "Retrieve Transcripts Of Calls",
66
description: "Retrieve transcripts of calls. [See the documentation](https://us-66463.app.gong.io/settings/api/documentation#post-/v2/calls/transcript)",
77
type: "action",
8-
version: "0.0.5",
8+
version: "0.0.6",
99
annotations: {
1010
destructiveHint: false,
1111
openWorldHint: true,

components/gong/gong.app.mjs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,16 +152,25 @@ export default {
152152
}) {
153153
let cursor;
154154
let resourcesCount = 0;
155+
let response;
155156

156157
while (true) {
157-
const response =
158+
try {
159+
response =
158160
await resourceFn({
159161
...resourceFnArgs,
160162
params: {
161163
...resourceFnArgs?.params,
162164
cursor,
163165
},
164166
});
167+
} catch (error) {
168+
if (error.response.status === 404) {
169+
console.log("No more resources");
170+
return;
171+
}
172+
throw error;
173+
}
165174

166175
const nextResources = resourceName && response[resourceName] || response;
167176

components/gong/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/gong",
3-
"version": "0.3.1",
3+
"version": "0.3.2",
44
"description": "Pipedream Gong Components",
55
"main": "gong.app.mjs",
66
"keywords": [
@@ -9,10 +9,10 @@
99
],
1010
"homepage": "https://pipedream.com/apps/gong",
1111
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
12-
"dependencies": {
13-
"@pipedream/platform": "^3.1.1"
14-
},
1512
"publishConfig": {
1613
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/platform": "^3.1.1"
1717
}
1818
}

components/gong/sources/common/polling.mjs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,12 @@ export default {
3939
const meta = this.generateMeta(resource);
4040
this.$emit(resource, meta);
4141
},
42-
async processResources(resources) {
43-
const descendingResources = Array.from(resources).reverse();
42+
async processResources(resources, max) {
43+
let descendingResources = Array.from(resources).reverse();
44+
45+
if (max) {
46+
descendingResources = descendingResources.slice(0, max);
47+
}
4448

4549
const [
4650
lastResource,
@@ -53,6 +57,17 @@ export default {
5357
descendingResources.forEach(this.processEvent);
5458
},
5559
},
60+
hooks: {
61+
async deploy() {
62+
const resources = await this.app.paginate({
63+
resourceFn: this.getResourceFn(),
64+
resourceFnArgs: this.getResourceFnArgs(),
65+
resourceName: this.getResourceName(),
66+
});
67+
68+
this.processResources(resources, 25);
69+
},
70+
},
5671
async run() {
5772
const resources = await this.app.paginate({
5873
resourceFn: this.getResourceFn(),

components/gong/sources/new-call/new-call.mjs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ export default {
44
...common,
55
key: "gong-new-call",
66
name: "New Call",
7-
description: "Triggers when a new call is added. [See the documentation](https://us-66463.app.gong.io/settings/api/documentation#get-/v2/calls)",
7+
description: "Emit new event when a new call is added. [See the documentation](https://us-66463.app.gong.io/settings/api/documentation#get-/v2/calls)",
88
type: "source",
9-
version: "0.0.3",
9+
version: "0.0.4",
1010
dedupe: "unique",
1111
methods: {
1212
...common.methods,
@@ -17,11 +17,11 @@ export default {
1717
return this.app.listCalls;
1818
},
1919
getResourceFnArgs() {
20-
const threeMonthsAgo = new Date();
21-
threeMonthsAgo.setMonth(threeMonthsAgo.getMonth() - 3);
20+
const oneDayAgo = new Date();
21+
oneDayAgo.setDate(oneDayAgo.getDate() - 1);
2222
return {
2323
params: {
24-
fromDateTime: this.getLastCreatedAt() || threeMonthsAgo.toISOString(),
24+
fromDateTime: this.getLastCreatedAt() || oneDayAgo.toISOString(),
2525
},
2626
};
2727
},

0 commit comments

Comments
 (0)