-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[connectors] Move all Zendesk garbage collection to the gc workflow (#…
…8748) * feat: move the brand garbage collection from the sync workflow to the gc workflow * refactor: add a function that deletes a brand for consistency * refactor: rename getZendeskCategoriesActivity with fetch (gonna use the name with a get) * refactor: move the deletion of the category to the function deleteCategory * feat: add a gc for the empty categories * lint * feat: only revoke permissions in the setPermissions instead of deleting the brand * fix: fix fetchBatchByBrandId * refactor: remove an unused function * feat: batch the ticket delete function * feat: batch all activities relative to deleting huge amounts of tickets or articles * refactor: rename garbageCollectCategories into removeEmptyCategories * refactor: rename garbageCollectTicket/Article into more explicit names * 📝 * feat: add a cleanup for the categories * refactor: shorten a few function names * refactor: remove an unused activity * bump the workflow version * fix: avoid unbounded promises by adding concurrent execution
- Loading branch information
1 parent
aaec62e
commit b7d896f
Showing
6 changed files
with
412 additions
and
189 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { getArticleInternalId } from "@connectors/connectors/zendesk/lib/id_conversions"; | ||
import { concurrentExecutor } from "@connectors/lib/async_utils"; | ||
import { deleteFromDataSource } from "@connectors/lib/data_sources"; | ||
import { | ||
ZendeskArticleResource, | ||
ZendeskCategoryResource, | ||
} from "@connectors/resources/zendesk_resources"; | ||
import type { DataSourceConfig } from "@connectors/types/data_source_config"; | ||
|
||
/** | ||
* Deletes all the data stored in the db and in the data source relative to a category (articles). | ||
*/ | ||
export async function deleteCategory({ | ||
connectorId, | ||
categoryId, | ||
dataSourceConfig, | ||
}: { | ||
connectorId: number; | ||
categoryId: number; | ||
dataSourceConfig: DataSourceConfig; | ||
}) { | ||
/// deleting the articles in the data source | ||
const articles = await ZendeskArticleResource.fetchByCategoryId({ | ||
connectorId, | ||
categoryId, | ||
}); | ||
await concurrentExecutor( | ||
articles, | ||
(article) => | ||
deleteFromDataSource( | ||
dataSourceConfig, | ||
getArticleInternalId(connectorId, article.articleId) | ||
), | ||
{ concurrency: 10 } | ||
); | ||
/// deleting the articles stored in the db | ||
await ZendeskArticleResource.deleteByCategoryId({ | ||
connectorId, | ||
categoryId, | ||
}); | ||
// deleting the category stored in the db | ||
await ZendeskCategoryResource.deleteByCategoryId({ connectorId, categoryId }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.