Skip to content

Commit

Permalink
keep lastSyncTimestamp and retentionPeriodDays separate
Browse files Browse the repository at this point in the history
  • Loading branch information
aubin-tchoi committed Mar 6, 2025
1 parent 7edf062 commit ce6bcc7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 11 deletions.
2 changes: 1 addition & 1 deletion connectors/src/connectors/gong/temporal/activities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export async function gongSyncTranscriptsActivity({
let pageCursor = null;
do {
const { transcripts, nextPageCursor } = await gongClient.getTranscripts({
startTimestamp: configuration.lastSyncTimestamp,
startTimestamp: configuration.getSyncStartTimestamp(),
pageCursor,
});
const callsMetadata = await getTranscriptsMetadata({
Expand Down
34 changes: 24 additions & 10 deletions connectors/src/resources/gong_resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,23 +87,37 @@ export class GongConfigurationResource extends BaseResource<GongConfigurationMod

async resetLastSyncTimestamp(): Promise<void> {
await this.update({
lastSyncTimestamp: this.retentionPeriodDays
? Date.now() - this.retentionPeriodDays * 24 * 60 * 60 * 1000
: null,
lastSyncTimestamp: null,
});
}

async setLastSyncTimestamp(timestamp: number): Promise<void> {
await this.update({
// Can't set a timestamp older than what is enforced by the retention period.
lastSyncTimestamp: this.retentionPeriodDays
? Math.max(
timestamp,
Date.now() - this.retentionPeriodDays * 24 * 60 * 60 * 1000
)
: timestamp,
lastSyncTimestamp: timestamp,
});
}

async setRetentionPeriodDays(
retentionPeriodDays: number | null
): Promise<void> {
await this.update({
retentionPeriodDays,
});
}

// Returns the timestamp to start syncing from.
getSyncStartTimestamp() {
if (!this.retentionPeriodDays) {
return this.lastSyncTimestamp;
}
if (!this.lastSyncTimestamp) {
return Date.now() - this.retentionPeriodDays * 24 * 60 * 60 * 1000;
}
return Math.max(
this.lastSyncTimestamp,
Date.now() - this.retentionPeriodDays * 24 * 60 * 60 * 1000
);
}
}

export type GongUserBlob = Omit<
Expand Down

0 comments on commit ce6bcc7

Please sign in to comment.