Skip to content

Commit c2b6c41

Browse files
committed
feat: refactor instrument record module and service to avoid circular dependency
1 parent 33bc7fc commit c2b6c41

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

apps/api/src/instrument-records/instrument-records.module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Module } from '@nestjs/common';
1+
import { forwardRef, Module } from '@nestjs/common';
22

33
import { GroupsModule } from '@/groups/groups.module';
44
import { InstrumentsModule } from '@/instruments/instruments.module';
@@ -12,7 +12,7 @@ import { InstrumentRecordsService } from './instrument-records.service';
1212
@Module({
1313
controllers: [InstrumentRecordsController],
1414
exports: [InstrumentRecordsService],
15-
imports: [GroupsModule, InstrumentsModule, SessionsModule, SubjectsModule],
15+
imports: [GroupsModule, InstrumentsModule, SessionsModule, forwardRef(() => SubjectsModule)],
1616
providers: [InstrumentMeasuresService, InstrumentRecordsService]
1717
})
1818
export class InstrumentRecordsModule {}

apps/api/src/instrument-records/instrument-records.service.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,14 @@ import { replacer, reviver, yearsPassed } from '@douglasneuroinformatics/libjs';
22
import { accessibleQuery, InjectModel } from '@douglasneuroinformatics/libnest';
33
import type { Model } from '@douglasneuroinformatics/libnest';
44
import { linearRegression } from '@douglasneuroinformatics/libstats';
5-
import { BadRequestException, Injectable, NotFoundException, UnprocessableEntityException } from '@nestjs/common';
5+
import {
6+
BadRequestException,
7+
forwardRef,
8+
Inject,
9+
Injectable,
10+
NotFoundException,
11+
UnprocessableEntityException
12+
} from '@nestjs/common';
613
import type { Json, ScalarInstrument } from '@opendatacapture/runtime-core';
714
import { DEFAULT_GROUP_NAME } from '@opendatacapture/schemas/core';
815
import type {
@@ -34,6 +41,7 @@ export class InstrumentRecordsService {
3441
private readonly instrumentMeasuresService: InstrumentMeasuresService,
3542
private readonly instrumentsService: InstrumentsService,
3643
private readonly sessionsService: SessionsService,
44+
@Inject(forwardRef(() => SubjectsService))
3745
private readonly subjectsService: SubjectsService
3846
) {}
3947

0 commit comments

Comments
 (0)