Skip to content
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

#4079 - Queue Monitoring - Schedulers Refactor (Part 7) #4179

Merged
merged 9 commits into from
Dec 27, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ export * from "./schedulers/esdc-integration/ecert-integration/ecert-part-time-f
export * from "./schedulers/esdc-integration/ecert-integration/ecert-part-time-process-integration.scheduler";
export * from "./schedulers/esdc-integration/ecert-integration/disbursement-receipts-integration.scheduler";
export * from "./schedulers/esdc-integration/federal-restrictions-integration/federal-restrictions-integration.scheduler";
export * from "./schedulers/esdc-integration/models/esdc.models";
export * from "./schedulers/esdc-integration/models/msfaa-file-result.models";
export * from "./schedulers/esdc-integration/msfaa-integration/msfaa-full-time-process-integration.scheduler";
export * from "./schedulers/esdc-integration/msfaa-integration/msfaa-part-time-process-integration.scheduler";
export * from "./schedulers/esdc-integration/sin-validation-integration/sin-validation-process-integration.scheduler";
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -84,25 +84,31 @@ describe(describeProcessorRootTest(QueueNames.ECEProcessIntegration), () => {
},
);
application.studentNumber = "1234567789";
const locationCode =
application.currentAssessment.offering.institutionLocation
.institutionCode;
await db.application.save(application);
// Queued job.
const mockedJob = mockBullJob<void>();

// Act
const result = await processor.processECERequest(mockedJob.job);
const result = await processor.processQueue(mockedJob.job);

const uploadedFile = getUploadedFile(sftpClientMock);
const fileDate = dayjs().format("YYYYMMDD");
expect(result).toEqual(
expect.arrayContaining([
{
summary: [
`The uploaded file: ${uploadedFile.remoteFilePath}`,
"The number of records: 1",
],
},
expect(result).toStrictEqual([
`Uploaded file ${uploadedFile.remoteFilePath}, with 1 record(s).`,
]);
expect(
mockedJob.containLogMessages([
"Retrieving eligible COEs for ECE request.",
"Found 1 COEs.",
"Creating ECE request content.",
`Processing content for institution code ${locationCode}.`,
"Uploading content.",
`Uploaded file ${uploadedFile.remoteFilePath}, with 1 record(s).`,
]),
);
).toBe(true);
// Assert file output.
const [header, fileDetail, footer] = uploadedFile.fileLines;
// Expect the header to contain REQUEST and file date.
Expand Down Expand Up @@ -138,16 +144,10 @@ describe(describeProcessorRootTest(QueueNames.ECEProcessIntegration), () => {
const mockedJob = mockBullJob<void>();

// Act
const result = await processor.processECERequest(mockedJob.job);
const result = await processor.processQueue(mockedJob.job);

// Assert
expect(result).toEqual(
expect.arrayContaining([
{
summary: ["The uploaded file: none", "The number of records: 0"],
},
]),
);
expect(result).toStrictEqual(["No eligible COEs found."]);
});

function buildECEFileDetail(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { InjectQueue, Process, Processor } from "@nestjs/bull";
import { InjectQueue, Processor } from "@nestjs/bull";
import { ECEProcessingService } from "@sims/integrations/institution-integration/ece-integration";
import { QueueService } from "@sims/services/queue";
import { QueueNames } from "@sims/utilities";
import { InjectLogger, LoggerService } from "@sims/utilities/logger";
import {
InjectLogger,
LoggerService,
ProcessSummary,
} from "@sims/utilities/logger";
import { Job, Queue } from "bull";
import { QueueProcessSummaryResult } from "../../../models/processors.models";
import { BaseScheduler } from "../../base-scheduler";

@Processor(QueueNames.ECEProcessIntegration)
Expand All @@ -18,50 +21,35 @@ export class ECEProcessIntegrationScheduler extends BaseScheduler<void> {
super(schedulerQueue, queueService);
}

/**
* To be removed once the method {@link process} is implemented.
* This method "hides" the {@link Process} decorator from the base class.
*/
async processQueue(): Promise<string | string[]> {
throw new Error("Method not implemented.");
}

/**
* When implemented in a derived class, process the queue job.
* To be implemented.
*/
protected async process(): Promise<string | string[]> {
throw new Error("Method not implemented.");
}

/**
* Identifies all the applications that have an eligible COE request waiting
* for a particular institution.
* @params job details.
* @returns Processing result log.
* @param _job process job.
* @param processSummary process summary for logging.
* @returns processing result with uploaded files, if any.
*/
@Process()
async processECERequest(
job: Job<void>,
): Promise<QueueProcessSummaryResult[]> {
this.logger.log(
`Processing ECE request integration job ${job.id} of type ${job.name}.`,
protected async process(
_job: Job<void>,
processSummary: ProcessSummary,
): Promise<string[] | string> {
const uploadResults = await this.eceFileService.processECEFile(
processSummary,
);
this.logger.log("Executing ECE request file generation ...");
const uploadResults = await this.eceFileService.processECEFile();
this.logger.log("ECE request file generation completed.");

if (!uploadResults.length) {
return "No eligible COEs found.";
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

return uploadResults.map(
(uploadResult) =>
({
summary: [
`The uploaded file: ${uploadResult.generatedFile}`,
`The number of records: ${uploadResult.uploadedRecords}`,
],
} as QueueProcessSummaryResult),
`Uploaded file ${uploadResult.generatedFile}, with ${uploadResult.uploadedRecords} record(s).`,
);
}

/**
* Setting the logger here allows the correct context to be set
* during the property injection.
* Even if the logger is not used, it is required to be set, to
* allow the base classes to write logs using the correct context.
*/
@InjectLogger()
logger: LoggerService;
}
Loading
Loading