-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(Gong) - add an optional retention policy #11264
Conversation
ce6bcc7
to
584667b
Compare
19da437
to
2c40deb
Compare
This reverts commit da48897.
2c40deb
to
373d4f4
Compare
d92f873
to
ef487c2
Compare
b2b0402
to
4a1f733
Compare
# Conflicts: # connectors/src/connectors/gong/temporal/activities.ts
switch (configKey) { | ||
case RETENTION_PERIOD_CONFIG_KEY: { | ||
const configuration = await fetchGongConfiguration(connector); | ||
const retentionPeriodDays = configValue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might want to check the result of this with a Number.isFinite()
to avoid saving NaN
.
garbageCollectionStartTs: number; | ||
}) { | ||
let hasMoreTranscripts = true; | ||
while (hasMoreTranscripts) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use a do/while
to align with code above. Also do/while runs at least once 😉
return Date.now() - this.retentionPeriodDays * 24 * 60 * 60 * 1000; | ||
} | ||
return Math.max( | ||
this.lastSyncTimestamp, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure to see the value of this field? In both cases we add an SQL clause on a data field, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure I understand, does this make sense?
if (this.retentionPeriodDays && this.lastSyncTimestamp === null) {
return Date.now() - daysToMs(this.retentionPeriodDays);
}
return this.lastSyncTimestamp;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My question is more, why do we store the last GC timestamp? I don't see the value it brings?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh ok the comment line number bugged out
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I use it to prevent the gc from running every time: currentTimestamp - this.lastGarbageCollectionTimestamp > GC_FREQUENCY_MS
, it could be replaced with a modulo on the hour number but this seemed more simple to understand
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we could also run the GC every time, wdyt?
|
||
const retentionPeriodStart = | ||
garbageCollectionStartTs - | ||
configuration.retentionPeriodDays * 24 * 60 * 60 * 1000; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit
helper for days to ms.
* add retentionPeriodDays to GongConfigurationModel * add migration file * set lastSyncTimestamp based on the retention period * make lastSyncTimestamp non nullable * make lastSyncTimestamp non nullable in db * merge both sql migration scripts * add an activity that deleted outdated transcripts * add a column callDate * add migration script to create the new column * make retentionPeriodDays optional (keeps all transcripts) * add a garbage collect workflow * fix * keep lastSyncTimestamp and retentionPeriodDays separate * Revert "allow selecting the Transcripts folder" This reverts commit da48897. * add get/set configuration key methods * whitelist the new key * add the garbage collection as a child workflow of the main workflow * add baseUrl and retentionPeriodDays to the resource's toJSON * add a column lastGarbageCollectTimestamp to GongConfigurationModel * add the column lastGarbageCollectTimestamp to the db migration * rename the column * prevent the GC from running more than once a day * move the pagination on GC at the activity level instead of within a single activity * sort activity list * add lastGarbageCollectionTimestamp to toJSON * refactor: simplify checkGarbageCollectionState * pass along the garbageCollectionStartTs * rename * rename * correctly use the callDate * remove rebase artefact * refactor: uniformize a while into a do/while * add a Number.isFinite check on the parsed value for the retention period * add an util daysToMs
Description
This PR implements an optional retention policy.
This behavior is implemented using two things:
There is currently no UI for configuring it, it will be added to the
GongOptionComponent
in a follow up PR (get/set already there on the connector manager).The main workflow is updated to add an optional step of garbage collection:
lastGarbageCollectionTimestamp
in thegong_configuration
alongside the lastSyncTimestamp.retentionPeriodDays
, current date andlastGarbageCollectionTimestamp
).lastGarbageCollectionTimestamp
Tests
Risk
Deploy Plan
migration_62.sql
.