Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 584667b

Browse files
committedMar 6, 2025·
keep lastSyncTimestamp and retentionPeriodDays separate
1 parent 7edf062 commit 584667b

File tree

2 files changed

+25
-11
lines changed

2 files changed

+25
-11
lines changed
 

‎connectors/src/connectors/gong/temporal/activities.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export async function gongSyncTranscriptsActivity({
9999
let pageCursor = null;
100100
do {
101101
const { transcripts, nextPageCursor } = await gongClient.getTranscripts({
102-
startTimestamp: configuration.lastSyncTimestamp,
102+
startTimestamp: configuration.getSyncStartTimestamp(),
103103
pageCursor,
104104
});
105105
const callsMetadata = await getTranscriptsMetadata({

‎connectors/src/resources/gong_resources.ts

+24-10
Original file line numberDiff line numberDiff line change
@@ -87,23 +87,37 @@ export class GongConfigurationResource extends BaseResource<GongConfigurationMod
8787

8888
async resetLastSyncTimestamp(): Promise<void> {
8989
await this.update({
90-
lastSyncTimestamp: this.retentionPeriodDays
91-
? Date.now() - this.retentionPeriodDays * 24 * 60 * 60 * 1000
92-
: null,
90+
lastSyncTimestamp: null,
9391
});
9492
}
9593

9694
async setLastSyncTimestamp(timestamp: number): Promise<void> {
9795
await this.update({
98-
// Can't set a timestamp older than what is enforced by the retention period.
99-
lastSyncTimestamp: this.retentionPeriodDays
100-
? Math.max(
101-
timestamp,
102-
Date.now() - this.retentionPeriodDays * 24 * 60 * 60 * 1000
103-
)
104-
: timestamp,
96+
lastSyncTimestamp: timestamp,
10597
});
10698
}
99+
100+
async setRetentionPeriodDays(
101+
retentionPeriodDays: number | null
102+
): Promise<void> {
103+
await this.update({
104+
retentionPeriodDays,
105+
});
106+
}
107+
108+
// Returns the timestamp to start syncing from.
109+
getSyncStartTimestamp() {
110+
if (this.retentionPeriodDays) {
111+
if (!this.lastSyncTimestamp) {
112+
return Date.now() - this.retentionPeriodDays * 24 * 60 * 60 * 1000;
113+
}
114+
return Math.max(
115+
this.lastSyncTimestamp,
116+
Date.now() - this.retentionPeriodDays * 24 * 60 * 60 * 1000
117+
);
118+
}
119+
return this.lastSyncTimestamp;
120+
}
107121
}
108122

109123
export type GongUserBlob = Omit<

0 commit comments

Comments
 (0)
Please sign in to comment.