File tree 2 files changed +25
-11
lines changed
2 files changed +25
-11
lines changed Original file line number Diff line number Diff line change @@ -99,7 +99,7 @@ export async function gongSyncTranscriptsActivity({
99
99
let pageCursor = null ;
100
100
do {
101
101
const { transcripts, nextPageCursor } = await gongClient . getTranscripts ( {
102
- startTimestamp : configuration . lastSyncTimestamp ,
102
+ startTimestamp : configuration . getSyncStartTimestamp ( ) ,
103
103
pageCursor,
104
104
} ) ;
105
105
const callsMetadata = await getTranscriptsMetadata ( {
Original file line number Diff line number Diff line change @@ -87,23 +87,37 @@ export class GongConfigurationResource extends BaseResource<GongConfigurationMod
87
87
88
88
async resetLastSyncTimestamp ( ) : Promise < void > {
89
89
await this . update ( {
90
- lastSyncTimestamp : this . retentionPeriodDays
91
- ? Date . now ( ) - this . retentionPeriodDays * 24 * 60 * 60 * 1000
92
- : null ,
90
+ lastSyncTimestamp : null ,
93
91
} ) ;
94
92
}
95
93
96
94
async setLastSyncTimestamp ( timestamp : number ) : Promise < void > {
97
95
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 ,
105
97
} ) ;
106
98
}
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
+ }
107
121
}
108
122
109
123
export type GongUserBlob = Omit <
You can’t perform that action at this time.
0 commit comments