(result: DBResult)
| 79 | * @returns |
| 80 | */ |
| 81 | export function replaceLegacyValues(result: DBResult): DBResult { |
| 82 | //convert legacy values |
| 83 | if ( |
| 84 | result.correctChars !== undefined && |
| 85 | result.incorrectChars !== undefined |
| 86 | ) { |
| 87 | //super edge case but just in case |
| 88 | if (result.charStats !== undefined) { |
| 89 | result.charStats = [ |
| 90 | result.charStats[0], |
| 91 | result.charStats[1], |
| 92 | result.charStats[2], |
| 93 | result.charStats[3], |
| 94 | ]; |
| 95 | delete result.correctChars; |
| 96 | delete result.incorrectChars; |
| 97 | } else { |
| 98 | result.charStats = [result.correctChars, result.incorrectChars, 0, 0]; |
| 99 | delete result.correctChars; |
| 100 | delete result.incorrectChars; |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | if (typeof result.funbox === "string") { |
| 105 | if (result.funbox === "none") { |
| 106 | result.funbox = []; |
| 107 | } else { |
| 108 | result.funbox = (result.funbox as string).split("#") as FunboxName[]; |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | if ( |
| 113 | result.chartData !== undefined && |
| 114 | result.chartData !== "toolong" && |
| 115 | "raw" in result.chartData |
| 116 | ) { |
| 117 | const temp = result.chartData; |
| 118 | result.chartData = { |
| 119 | wpm: temp.wpm, |
| 120 | burst: temp.raw, |
| 121 | err: temp.err, |
| 122 | }; |
| 123 | } |
| 124 | |
| 125 | if (typeof result.mode2 === "number") { |
| 126 | result.mode2 = (result.mode2 as number).toString(); |
| 127 | } |
| 128 | |
| 129 | //legacy value for english_1k |
| 130 | if ((result.language as string) === "english_expanded") { |
| 131 | result.language = "english_1k"; |
| 132 | } |
| 133 | |
| 134 | return result; |
| 135 | } |
no test coverage detected