Skip to content

functionality to implement reset needs evaluation flag #654

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Aug 20, 2025
13 changes: 7 additions & 6 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const { defineConfig } = require('eslint/config');
import defineConfig from 'eslint/config';
import tsParser from '@typescript-eslint/parser';

const tsParser = require('@typescript-eslint/parser');
const typescriptEslintEslintPlugin = require('@typescript-eslint/eslint-plugin');
const globals = require('globals');
const js = require('@eslint/js');
import typescriptEslintEslintPlugin from '@typescript-eslint/eslint-plugin';
import globals from 'globals';

const { FlatCompat } = require('@eslint/eslintrc');
import js from '@eslint/js';
import FlatCompat from '@eslint/eslintrc';

const compat = new FlatCompat({
baseDirectory: __dirname,
Expand Down Expand Up @@ -43,6 +43,7 @@ module.exports = defineConfig([
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'prettier/prettier': ['error', { endOfLine: 'auto' }],
},
},
]);
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const mockRepository = () => ({
create: jest.fn().mockResolvedValue(entity),
save: jest.fn().mockResolvedValue(entity),
delete: jest.fn().mockResolvedValue(null),
query: jest.fn().mockResolvedValue(['']),
});

const mockQACertRepository = () => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,11 @@ export class QACertificationEventWorkspaceService {

await this.repository.save(entity);

const result = await this.repository.getQACertificationEventById(entity.id);
//Finally, perform the updates (reset needs eval flag, etc) for those records
// that may have been collaterally affected by this change.
await this.updateCollaterallyAffectedRecords(entity.id);

const result = await this.repository.getQACertificationEventById(entity.id);
return this.map.one(result);
}

Expand Down Expand Up @@ -161,6 +164,10 @@ export class QACertificationEventWorkspaceService {
async deleteQACertEvent(id: string): Promise<void> {
try {
await this.repository.delete(id);

//Finally, perform the updates (reset needs eval flag, etc) for those records
// that may have been collaterally affected by this change.
await this.updateCollaterallyAffectedRecords(id);
} catch (e) {
throw new InternalServerErrorException(
`Error deleting QA Certification Event record Id [${id}]`,
Expand Down Expand Up @@ -233,9 +240,26 @@ export class QACertificationEventWorkspaceService {

await this.repository.save(entity);

//Finally, perform the updates (reset needs eval flag, etc) for those records
// that may have been collaterally affected by this change.
await this.updateCollaterallyAffectedRecords(entity.id);

return this.getQACertEvent(entity.id);
}

async updateCollaterallyAffectedRecords(qceId: string): Promise<void> {

//1. Update affected EM Records
const emResult = await this.repository.query(
'SELECT * FROM camdecmpswks.update_collateral_em_data_for_qce_changes($1)',
[qceId],
);

if (emResult[0].result === 'F') {
throw new Error(`EM Deletion Failed: ${emResult[0].error_msg}`);
}
}

async export(
facilityId: number,
unitIds?: string[],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ const mockRepository = () => ({
findOneBy: jest.fn().mockResolvedValue(entity),
create: jest.fn().mockResolvedValue(entity),
save: jest.fn().mockResolvedValue(entity),
query: jest.fn().mockResolvedValue(['']),
});

const mockTestExtensionExemptionsRepository = () => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,13 @@ export class TestExtensionExemptionsWorkspaceService {

await this.repository.save(entity);

//Finally, perform the updates (reset needs eval flag, etc) for those records
// that may have been collaterally affected by this change.
await this.updateCollaterallyAffectedRecords(entity.id);

const result = await this.repository.getTestExtensionExemptionById(
entity.id,
);

return this.map.one(result);
}

Expand Down Expand Up @@ -259,12 +262,21 @@ export class TestExtensionExemptionsWorkspaceService {
record.submissionAvailabilityCode = 'REQUIRE';

await this.repository.save(record);

//Finally, perform the updates (reset needs eval flag, etc) for those records
// that may have been collaterally affected by this change.
await this.updateCollaterallyAffectedRecords(record.id);

return this.getTestExtensionExemptionById(record.id);
}

async deleteTestExtensionExemption(id: string): Promise<void> {
try {
await this.repository.delete(id);

//Finally, perform the updates (reset needs eval flag, etc) for those records
// that may have been collaterally affected by this change.
await this.updateCollaterallyAffectedRecords(id);
} catch (e) {
throw new InternalServerErrorException(
`Error deleting Test Extension Exemption record Id [${id}]`,
Expand All @@ -273,6 +285,19 @@ export class TestExtensionExemptionsWorkspaceService {
}
}

async updateCollaterallyAffectedRecords(teeId: string): Promise<void> {

//1. Update affected EM Records
const emResult = await this.repository.query(
'SELECT * FROM camdecmpswks.update_collateral_em_data_for_tee_changes($1)',
[teeId],
);

if (emResult[0].result === 'F') {
throw new Error(`EM Deletion Failed: ${emResult[0].error_msg}`);
}
}

async lookupValues(
locationId: string,
payload: TestExtensionExemptionBaseDTO,
Expand Down
1 change: 1 addition & 0 deletions src/test-summary-workspace/test-summary.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ const mockRepository = () => ({
findOneBy: jest.fn().mockResolvedValue(testSummary),
create: jest.fn().mockResolvedValue(testSummary),
save: jest.fn().mockResolvedValue(testSummary),
query: jest.fn().mockResolvedValue(['']),
});

const mockTestSummaryReviewAndSubmitService = () => ({
Expand Down
40 changes: 39 additions & 1 deletion src/test-summary-workspace/test-summary.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -703,8 +703,12 @@ export class TestSummaryWorkspaceService {
});

await this.repository.save(entity);
const result = await this.repository.getTestSummaryById(entity.id);

// Perform the updates (reset needs eval flag, etc) for those records
// that may have been collaterally affected by this change.
await this.updateCollaterallyAffectedRecords(entity.id);

const result = await this.repository.getTestSummaryById(entity.id);
const dto = await this.map.one(result);

delete dto.calibrationInjectionData;
Expand Down Expand Up @@ -776,12 +780,21 @@ export class TestSummaryWorkspaceService {
entity.evalStatusCode = 'EVAL';

await this.repository.save(entity);

// Perform the updates (reset needs eval flag, etc) for those records
// that may have been collaterally affected by this change.
await this.updateCollaterallyAffectedRecords(entity.id);

return this.getTestSummaryById(entity.id);
}

async deleteTestSummary(id: string): Promise<void> {
try {
await this.repository.delete(id);

// Perform the updates (reset needs eval flag, etc) for those records
// that may have been collaterally affected by this change.
await this.updateCollaterallyAffectedRecords(id);
} catch (e) {
throw new InternalServerErrorException(
`Error deleting Test Summary record Id [${id}]`,
Expand All @@ -806,6 +819,31 @@ export class TestSummaryWorkspaceService {
entity.evalStatusCode = 'EVAL';

await this.repository.save(entity);

//Finally, perform the updates (reset needs eval flag, etc) for those records
// that may have been collaterally affected by this change.
await this.updateCollaterallyAffectedRecords(testSumId);
}
}

async updateCollaterallyAffectedRecords(testSumId: string): Promise<void> {
//1. Update affected QAT Records
const qaResult = await this.repository.query(
'SELECT * FROM camdecmpswks.update_collateral_qat_data_for_qat_changes($1)',
[testSumId],
);
if (qaResult[0].result === 'F') {
throw new Error(`QA Deletion Failed: ${qaResult[0].error_msg}`);
}

//2. Update affected EM Records
const emResult = await this.repository.query(
'SELECT * FROM camdecmpswks.update_collateral_em_data_for_qat_changes($1)',
[testSumId],
);

if (emResult[0].result === 'F') {
throw new Error(`EM Deletion Failed: ${emResult[0].error_msg}`);
}
}

Expand Down