( baseStatus: ImportStatus, jobType?: "wakatime-api" | "wakatime-file" | "wakapi", current?: number, total?: number, progress?: number, additionalInfo?: string, importedCount?: number, error?: string, )
| 25 | } |
| 26 | |
| 27 | function formatStatus( |
| 28 | baseStatus: ImportStatus, |
| 29 | jobType?: "wakatime-api" | "wakatime-file" | "wakapi", |
| 30 | current?: number, |
| 31 | total?: number, |
| 32 | progress?: number, |
| 33 | additionalInfo?: string, |
| 34 | importedCount?: number, |
| 35 | error?: string, |
| 36 | ): string { |
| 37 | const methodPrefix = getMethodName(jobType); |
| 38 | const hasProgress = current !== undefined && total !== undefined && total > 0; |
| 39 | const progressStr = progress !== undefined ? ` (${progress}%)` : ""; |
| 40 | |
| 41 | switch (baseStatus) { |
| 42 | case ImportStatus.ProcessingHeartbeats: |
| 43 | if (hasProgress) { |
| 44 | const info = additionalInfo ? ` ${additionalInfo}` : ""; |
| 45 | return `[${methodPrefix}] Importing data: ${current}/${total} days${info}${progressStr}`; |
| 46 | } |
| 47 | return additionalInfo |
| 48 | ? `[${methodPrefix}] Importing data: ${additionalInfo}${progressStr}` |
| 49 | : `[${methodPrefix}] Importing data${progressStr}`; |
| 50 | |
| 51 | case ImportStatus.Uploading: |
| 52 | if (hasProgress) { |
| 53 | const currentMB = (current / (1024 * 1024)).toFixed(1); |
| 54 | const totalMB = (total / (1024 * 1024)).toFixed(1); |
| 55 | return `[${methodPrefix}] Uploading: ${currentMB}MB/${totalMB}MB${progressStr}`; |
| 56 | } |
| 57 | if (additionalInfo) { |
| 58 | return `[${methodPrefix}] Uploading: ${additionalInfo}${progressStr}`; |
| 59 | } |
| 60 | return `[${methodPrefix}] Uploading${progressStr}`; |
| 61 | |
| 62 | case ImportStatus.Processing: |
| 63 | if (hasProgress) { |
| 64 | return `[${methodPrefix}] Processing: ${current}/${total} items${progressStr}`; |
| 65 | } |
| 66 | return `[${methodPrefix}] Processing${progressStr}`; |
| 67 | |
| 68 | case ImportStatus.CreatingDataDumpRequest: |
| 69 | return `[${methodPrefix}] Creating Data Dump Request${progressStr}`; |
| 70 | |
| 71 | case ImportStatus.WaitingForDataDump: |
| 72 | return `[${methodPrefix}] Waiting for Data Dump${progressStr}`; |
| 73 | |
| 74 | case ImportStatus.Downloading: |
| 75 | if (additionalInfo) { |
| 76 | return `[${methodPrefix}] Downloading: ${additionalInfo}${progressStr}`; |
| 77 | } |
| 78 | return `[${methodPrefix}] Downloading Data Dump${progressStr}`; |
| 79 | |
| 80 | case ImportStatus.FetchingMetadata: |
| 81 | return `[${methodPrefix}] Fetching Metadata${progressStr}`; |
| 82 | |
| 83 | case ImportStatus.Completed: |
| 84 | if (importedCount) { |
no test coverage detected