-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[parents_migration] Add and backfill Google Drive "Shared with me" fo…
…lders (#9507) * create and delete SharedWithMe folder * add backfill script * add concurrency on the script * fix the internalId of the sharedWithMe folder * use the dataSourceId in the SharedWithMe folder id instead of the connector ID * move the deletion of the shared with me folder to the clean method * use dataSourceId in the folderId for the sharedWithMe folder * delete from core first * remove the dataSourceId from the GOOGLE_DRIVE_SHARED_WITH_ME_VIRTUAL_ID folder * cleanup * remove the delete, leaving it for another task * inline upsertSharedWithMeFolder * move the upsertion to an activity
- Loading branch information
1 parent
ded1e01
commit 5176705
Showing
5 changed files
with
70 additions
and
6 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
connectors/migrations/20241218_backfill_gdrive_shared_with_me.ts
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,37 @@ | ||
import { makeScript } from "scripts/helpers"; | ||
|
||
import { GOOGLE_DRIVE_SHARED_WITH_ME_VIRTUAL_ID } from "@connectors/connectors/google_drive/lib/consts"; | ||
import { getInternalId } from "@connectors/connectors/google_drive/temporal/utils"; | ||
import { dataSourceConfigFromConnector } from "@connectors/lib/api/data_source_config"; | ||
import { concurrentExecutor } from "@connectors/lib/async_utils"; | ||
import { upsertDataSourceFolder } from "@connectors/lib/data_sources"; | ||
import { ConnectorResource } from "@connectors/resources/connector_resource"; | ||
|
||
makeScript({}, async ({ execute }, logger) => { | ||
const connectors = await ConnectorResource.listByType("google_drive", {}); | ||
|
||
await concurrentExecutor( | ||
connectors, | ||
async (connector) => { | ||
const folderId = getInternalId(GOOGLE_DRIVE_SHARED_WITH_ME_VIRTUAL_ID); | ||
if (execute) { | ||
await upsertDataSourceFolder({ | ||
dataSourceConfig: dataSourceConfigFromConnector(connector), | ||
folderId, | ||
parents: [folderId], | ||
parentId: null, | ||
title: "Shared with me", | ||
mimeType: "application/vnd.dust.googledrive.folder", | ||
}); | ||
logger.info( | ||
`Upserted folder ${folderId} for connector ${connector.id}` | ||
); | ||
} else { | ||
logger.info( | ||
`Would upsert folder ${folderId} for connector ${connector.id}` | ||
); | ||
} | ||
}, | ||
{ concurrency: 10 } | ||
); | ||
}); |
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
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