Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
import { ComposedFederatedGraph } from '../composition/composer.js';
import { SchemaDiff } from '../composition/schemaCheck.js';
import { InspectorOperationResult } from '../services/SchemaUsageTrafficInspector.js';
import { createBatches } from '../util.js';
import { FederatedGraphConfig } from './FederatedGraphRepository.js';

export class SchemaCheckRepository {
Expand Down Expand Up @@ -120,7 +121,11 @@ export class SchemaCheckRepository {
return;
}

await this.db.insert(schemaCheckChangeActionOperationUsage).values(values).execute();
const arrayOfValues: NewSchemaChangeOperationUsage[][] = createBatches<NewSchemaChangeOperationUsage>(values, 500);

for (const values of arrayOfValues) {
await this.db.insert(schemaCheckChangeActionOperationUsage).values(values).execute();
}
}

private mapChangesFromDriverValue = (val: any) => {
Expand Down
11 changes: 11 additions & 0 deletions controlplane/src/core/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -427,3 +427,14 @@ export function mergeUrls(baseUrl: string, relativeUrl: string) {

return new URL(relativeUrl, baseUrl).toString();
}

export function createBatches<T>(array: T[], batchSize: number): T[][] {
const batches: T[][] = [];

for (let i = 0; i < array.length; i += batchSize) {
const batch = array.slice(i, i + batchSize);
batches.push(batch);
}

return batches;
}