Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion components/gong/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/gong",
"version": "0.4.1",
"version": "0.4.2",
"description": "Pipedream Gong Components",
"main": "gong.app.mjs",
"keywords": [
Expand Down
35 changes: 34 additions & 1 deletion components/gong/sources/common/polling.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ import {
import common from "./base.mjs";
import constants from "../../common/constants.mjs";

// Gong makes a call queryable only once it has finished processing it, which
// can be well after the time the call started, and `fromDateTime` filters on
// that start time server-side. So a cursor that jumps straight to the newest
// start time it has seen hides every call still being processed behind it, and
// hides it permanently: no later poll ever asks for that range again. Holding
// the cursor this far behind the present keeps those calls inside the next
// poll's window instead. The calls that get read a second time as a result are
// dropped by `dedupe: "unique"`.
const PROCESSING_LAG_MS = 60 * 60 * 1000;

export default {
...common,
props: {
Expand All @@ -26,6 +36,26 @@ export default {
getLastCreatedAt() {
return this.db.get(constants.LAST_CREATED_AT);
},
nextLastCreatedAt(newest) {
const previous = this.getLastCreatedAt();
const newestMs = Date.parse(newest);

if (Number.isNaN(newestMs)) {
return previous;
}

const held = Math.min(newestMs, Date.now() - PROCESSING_LAG_MS);
const previousMs = Date.parse(previous);

// Never hand back a cursor older than the one already stored: an account
// recording more calls per lag window than a single poll reads would
// otherwise stop making progress.
const next = Number.isNaN(previousMs)
? held
: Math.max(previousMs, held);
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated

return new Date(next).toISOString();
},
getResourceName() {
throw new ConfigurationError("getResourceName is not implemented");
},
Expand All @@ -51,7 +81,10 @@ export default {
] = descendingResources;

if (lastResource?.started) {
this.setLastCreatedAt(lastResource.started);
const next = this.nextLastCreatedAt(lastResource.started);
if (next) {
this.setLastCreatedAt(next);
}
}

descendingResources.forEach(this.processEvent);
Expand Down
2 changes: 1 addition & 1 deletion components/gong/sources/new-call/new-call.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
name: "New Call",
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)",
type: "source",
version: "0.0.5",
version: "0.0.6",
dedupe: "unique",
methods: {
...common.methods,
Expand Down
Loading