(
chunk: WorkChunk,
workerId: number,
)
| 470 | } |
| 471 | |
| 472 | private async processWorkChunk( |
| 473 | chunk: WorkChunk, |
| 474 | workerId: number, |
| 475 | ): Promise<void> { |
| 476 | try { |
| 477 | const jobId = chunk.jobId; |
| 478 | const job = activeJobs.get(jobId); |
| 479 | if (!job) { |
| 480 | handleLog(`Job ${jobId} not found for chunk ${chunk.id}`); |
| 481 | return; |
| 482 | } |
| 483 | if (chunk.type === "date-range" && chunk.data.days) { |
| 484 | await this.processDateRangeChunk(chunk, job, workerId); |
| 485 | } |
| 486 | |
| 487 | chunk.status = "completed"; |
| 488 | chunk.progress = 100; |
| 489 | |
| 490 | const completedSet = this.completedChunks.get(chunk.jobId); |
| 491 | if (completedSet) { |
| 492 | completedSet.add(chunk.id); |
| 493 | } |
| 494 | |
| 495 | this.updateJobProgress(chunk.jobId); |
| 496 | await this.checkJobCompletion(chunk.jobId); |
| 497 | } catch (error) { |
| 498 | chunk.status = "failed"; |
| 499 | handleLog(`Worker ${workerId} failed chunk ${chunk.id}: ${error}`); |
| 500 | } finally { |
| 501 | this.cleanupWorkerAssignment(workerId); |
| 502 | } |
| 503 | } |
| 504 | |
| 505 | private async processDateRangeChunk( |
| 506 | chunk: WorkChunk, |
no test coverage detected