Skip to content

Commit 53d7eae

Browse files
authored
fix: fetch breaking operations and clients in parallel to improve lat… (#6431)
1 parent ab06518 commit 53d7eae

File tree

1 file changed

+15
-21
lines changed

1 file changed

+15
-21
lines changed

packages/services/api/src/modules/schema/providers/registry-checks.ts

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -496,31 +496,25 @@ export class RegistryChecks {
496496
// Since the affected clients query is lighter it makes more sense to run it first and skip running
497497
// the operations query if no clients are affected, as it will also yield zero results in that case.
498498

499-
const topAffectedClients = await this.operationsReader.getTopClientsForSchemaCoordinate(
500-
{
499+
const [topAffectedClients, topAffectedOperations] = await Promise.all([
500+
this.operationsReader.getTopClientsForSchemaCoordinate({
501501
targetIds: settings.targetIds,
502502
excludedClients: settings.excludedClientNames,
503503
period: settings.period,
504504
schemaCoordinate: change.breakingChangeSchemaCoordinate,
505-
},
506-
);
507-
508-
if (topAffectedClients) {
509-
const topAffectedOperations =
510-
await this.operationsReader.getTopOperationsForSchemaCoordinate({
511-
targetIds: settings.targetIds,
512-
excludedClients: settings.excludedClientNames,
513-
period: settings.period,
514-
schemaCoordinate: change.breakingChangeSchemaCoordinate,
515-
});
516-
517-
if (topAffectedOperations) {
518-
change.usageStatistics = {
519-
topAffectedOperations,
520-
topAffectedClients,
521-
};
522-
}
523-
}
505+
}),
506+
this.operationsReader.getTopOperationsForSchemaCoordinate({
507+
targetIds: settings.targetIds,
508+
excludedClients: settings.excludedClientNames,
509+
period: settings.period,
510+
schemaCoordinate: change.breakingChangeSchemaCoordinate,
511+
}),
512+
]);
513+
514+
change.usageStatistics = {
515+
topAffectedOperations: topAffectedOperations ?? [],
516+
topAffectedClients: topAffectedClients ?? [],
517+
};
524518
}
525519

526520
change.isSafeBasedOnUsage = !isBreaking;

0 commit comments

Comments
 (0)