Skip to content

Commit

Permalink
Use infer for types of config values.
Browse files Browse the repository at this point in the history
  • Loading branch information
mkreuzkam-cap committed Jan 21, 2025
1 parent 14764a7 commit 768d1bf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export class TspSyncMigrationService {

private getOldIdBatches(oldToNewMappings: Map<string, string>): string[][] {
const oldIds = Array.from(oldToNewMappings.keys());
const batchSize = this.configService.getOrThrow<number>('TSP_SYNC_MIGRATION_LIMIT');
const batchSize = this.configService.getOrThrow('TSP_SYNC_MIGRATION_LIMIT', { infer: true });

const batchCount = Math.ceil(oldIds.length / batchSize);
const batches: string[][] = [];
Expand Down
10 changes: 5 additions & 5 deletions apps/server/src/infra/sync/strategy/tsp/tsp-sync.strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,19 @@ export class TspSyncStrategy extends SyncStrategy {

const schools = await this.tspSyncService.findSchoolsForSystem(system);

if (this.configService.getOrThrow<boolean>('FEATURE_TSP_MIGRATION_ENABLED')) {
if (this.configService.getOrThrow('FEATURE_TSP_MIGRATION_ENABLED', { infer: true })) {
await this.runMigration(system);
}

await this.syncData(system, schools);
}

private async syncSchools(system: System): Promise<School[]> {
const schoolDaysToFetch = this.configService.getOrThrow<number>('TSP_SYNC_SCHOOL_DAYS_TO_FETCH');
const schoolDaysToFetch = this.configService.getOrThrow('TSP_SYNC_SCHOOL_DAYS_TO_FETCH', { infer: true });
const tspSchools = await this.tspFetchService.fetchTspSchools(system, schoolDaysToFetch);
this.logger.info(new TspSchoolsFetchedLoggable(tspSchools.length, schoolDaysToFetch));

const schoolLimit = this.configService.getOrThrow<number>('TSP_SYNC_SCHOOL_LIMIT');
const schoolLimit = this.configService.getOrThrow('TSP_SYNC_SCHOOL_LIMIT', { infer: true });
const schoolLimitFn = pLimit(schoolLimit);

const schoolPromises = tspSchools.map((tspSchool) =>
Expand Down Expand Up @@ -100,7 +100,7 @@ export class TspSyncStrategy extends SyncStrategy {
}

private async syncData(system: System, schools: School[]): Promise<void> {
const schoolDataDaysToFetch = this.configService.getOrThrow<number>('TSP_SYNC_DATA_DAYS_TO_FETCH');
const schoolDataDaysToFetch = this.configService.getOrThrow('TSP_SYNC_DATA_DAYS_TO_FETCH', { infer: true });
const tspTeachers = await this.tspFetchService.fetchTspTeachers(system, schoolDataDaysToFetch);
const tspStudents = await this.tspFetchService.fetchTspStudents(system, schoolDataDaysToFetch);
const tspClasses = await this.tspFetchService.fetchTspClasses(system, schoolDataDaysToFetch);
Expand All @@ -118,7 +118,7 @@ export class TspSyncStrategy extends SyncStrategy {

this.logger.info(new TspSyncingUsersLoggable(oauthDataDtos.length));

const dataLimit = this.configService.getOrThrow<number>('TSP_SYNC_DATA_LIMIT');
const dataLimit = this.configService.getOrThrow('TSP_SYNC_DATA_LIMIT', { infer: true });
const dataLimitFn = pLimit(dataLimit);

const dataPromises = oauthDataDtos.map((oauthDataDto) =>
Expand Down

0 comments on commit 768d1bf

Please sign in to comment.