(jobId: string)
| 615 | } |
| 616 | |
| 617 | private async checkJobCompletion(jobId: string): Promise<void> { |
| 618 | const jobChunks = Array.from(this.workChunks.values()).filter( |
| 619 | (c) => c.jobId === jobId, |
| 620 | ); |
| 621 | const completedChunks = jobChunks.filter((c) => c.status === "completed"); |
| 622 | |
| 623 | if (completedChunks.length === jobChunks.length && jobChunks.length > 0) { |
| 624 | const job = activeJobs.get(jobId); |
| 625 | if (job) { |
| 626 | const totalDaysWithData = jobChunks.reduce( |
| 627 | (sum, chunk) => sum + (chunk.data.processedDays || 0), |
| 628 | 0, |
| 629 | ); |
| 630 | |
| 631 | updateJob(job, { |
| 632 | status: ImportStatus.Completed, |
| 633 | importedCount: totalDaysWithData, |
| 634 | }); |
| 635 | handleLog( |
| 636 | `[${getLogPrefix(job.type)}] Job ${jobId} completed - processed ${totalDaysWithData} days across ${jobChunks.length} chunks`, |
| 637 | ); |
| 638 | } |
| 639 | |
| 640 | jobChunks.forEach((chunk) => this.workChunks.delete(chunk.id)); |
| 641 | this.jobWorkerCount.delete(jobId); |
| 642 | this.completedChunks.delete(jobId); |
| 643 | } |
| 644 | } |
| 645 | |
| 646 | private async processJob(job: QueueJob, workerId: number): Promise<void> { |
| 647 | try { |
no test coverage detected