(
jobLogger: ILogger,
job: {
updateProgress: (progress: Record<string, any>) => void;
},
importId: string,
options: UpdateImportStatusOptions
)
| 655 | export type ImportSteps = UpdateImportStatusOptions['step']; |
| 656 | |
| 657 | export async function updateImportStatus( |
| 658 | jobLogger: ILogger, |
| 659 | job: { |
| 660 | updateProgress: (progress: Record<string, any>) => void; |
| 661 | }, |
| 662 | importId: string, |
| 663 | options: UpdateImportStatusOptions |
| 664 | ): Promise<void> { |
| 665 | const data: Prisma.ImportUpdateInput = {}; |
| 666 | switch (options.step) { |
| 667 | case 'loading': |
| 668 | data.status = 'processing'; |
| 669 | data.currentStep = 'loading'; |
| 670 | data.currentBatch = options.batch; |
| 671 | data.statusMessage = options.batch |
| 672 | ? `Importing events from ${options.batch}` |
| 673 | : 'Initializing...'; |
| 674 | data.totalEvents = options.totalEvents; |
| 675 | data.processedEvents = options.processedEvents; |
| 676 | break; |
| 677 | case 'loading_profiles': |
| 678 | data.currentStep = 'loading_profiles'; |
| 679 | data.statusMessage = |
| 680 | options.processedProfiles != null && options.totalProfiles != null |
| 681 | ? `Importing user profiles (${options.processedProfiles} / ${options.totalProfiles})` |
| 682 | : 'Importing user profiles...'; |
| 683 | break; |
| 684 | case 'creating_sessions': |
| 685 | data.currentStep = 'creating_sessions'; |
| 686 | data.currentBatch = options.batch; |
| 687 | data.statusMessage = options.batch |
| 688 | ? `Creating sessions (${options.batch})` |
| 689 | : 'Creating sessions...'; |
| 690 | break; |
| 691 | case 'generating_sessions': |
| 692 | data.currentStep = 'generating_sessions'; |
| 693 | data.statusMessage = 'Generating session IDs...'; |
| 694 | break; |
| 695 | case 'moving': |
| 696 | data.currentStep = 'moving'; |
| 697 | data.currentBatch = options.batch; |
| 698 | data.statusMessage = `Moving events to production (${options.batch})`; |
| 699 | break; |
| 700 | case 'backfilling_sessions': |
| 701 | data.currentStep = 'backfilling_sessions'; |
| 702 | data.currentBatch = options.batch; |
| 703 | data.statusMessage = options.batch |
| 704 | ? `Aggregating sessions (${options.batch})` |
| 705 | : 'Aggregating sessions...'; |
| 706 | break; |
| 707 | case 'completed': |
| 708 | data.status = 'completed'; |
| 709 | data.currentStep = 'completed'; |
| 710 | data.statusMessage = 'Import completed'; |
| 711 | data.completedAt = new Date(); |
| 712 | break; |
| 713 | case 'failed': |
| 714 | data.status = 'failed'; |
no test coverage detected