mirror of
https://github.com/hcengineering/platform.git
synced 2024-12-19 08:51:37 +03:00
Add optional size parameter to move method for (#7442)
This commit is contained in:
parent
294aceffc1
commit
4e7d201560
@ -99,7 +99,12 @@ export interface MigrationClient {
|
||||
) => Promise<void>
|
||||
|
||||
// Move documents per domain
|
||||
move: <T extends Doc>(sourceDomain: Domain, query: DocumentQuery<T>, targetDomain: Domain) => Promise<void>
|
||||
move: <T extends Doc>(
|
||||
sourceDomain: Domain,
|
||||
query: DocumentQuery<T>,
|
||||
targetDomain: Domain,
|
||||
size?: number
|
||||
) => Promise<void>
|
||||
|
||||
create: <T extends Doc>(domain: Domain, doc: T | T[]) => Promise<void>
|
||||
delete: <T extends Doc>(domain: Domain, _id: Ref<T>) => Promise<void>
|
||||
|
@ -70,11 +70,16 @@ export class MigrateClientImpl implements MigrationClient {
|
||||
}
|
||||
}
|
||||
|
||||
async move<T extends Doc>(sourceDomain: Domain, query: DocumentQuery<T>, targetDomain: Domain): Promise<void> {
|
||||
async move<T extends Doc>(
|
||||
sourceDomain: Domain,
|
||||
query: DocumentQuery<T>,
|
||||
targetDomain: Domain,
|
||||
size = 500
|
||||
): Promise<void> {
|
||||
const ctx = new MeasureMetricsContext('move', {})
|
||||
this.logger.log('move', { sourceDomain, query })
|
||||
while (true) {
|
||||
const source = await this.lowLevel.rawFindAll(sourceDomain, query, { limit: 500 })
|
||||
const source = await this.lowLevel.rawFindAll(sourceDomain, query, { limit: size })
|
||||
if (source.length === 0) break
|
||||
await this.lowLevel.upload(ctx, targetDomain, source)
|
||||
await this.lowLevel.clean(
|
||||
|
@ -332,7 +332,7 @@ export const githubOperationPreTime: MigrateOperation = {
|
||||
{
|
||||
state: 'migrate-github-sync-domain',
|
||||
func: async (client) => {
|
||||
await client.move(DOMAIN_GITHUB, { _class: github.class.DocSyncInfo }, DOMAIN_GITHUB_SYNC)
|
||||
await client.move(DOMAIN_GITHUB, { _class: github.class.DocSyncInfo }, DOMAIN_GITHUB_SYNC, 100)
|
||||
await client.move(DOMAIN_GITHUB, { _class: github.class.GithubUserInfo }, DOMAIN_GITHUB_USER)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user