mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-03-01 09:14:27 +08:00
Merge branch 'master' into newads
This commit is contained in:
commit
7aa0214af5
4 changed files with 35 additions and 53 deletions
|
@ -129,7 +129,7 @@ Follow these steps if you want to work on anything involving the database/accoun
|
|||
npm run dev-fe
|
||||
```
|
||||
|
||||
These commands will start a local dev server on [port 3000](http://localhost:3000). It will watch for changes and rebuild when you edit files in `src/` or `public/` directories. Use `Ctrl+C` to stop it.
|
||||
These commands will start a local dev server on [port 3000](http://localhost:3000). It will watch for changes and rebuild when you edit files in `src/` or `public/` directories. Use <kbd>Ctrl+C</kbd> to stop it.
|
||||
|
||||
Note: Rebuilding doesn't happen instantaneously and depends on your machine, so be patient for changes to appear.
|
||||
|
||||
|
|
|
@ -322,15 +322,12 @@ export const accountHistory: ChartWithUpdateColors<
|
|||
x: {
|
||||
axis: "x",
|
||||
type: "linear",
|
||||
reverse: true,
|
||||
min: 0,
|
||||
ticks: {
|
||||
stepSize: 10,
|
||||
},
|
||||
display: false,
|
||||
title: {
|
||||
display: true,
|
||||
text: "Test Number",
|
||||
},
|
||||
grid: {
|
||||
display: false,
|
||||
},
|
||||
|
|
|
@ -275,8 +275,6 @@ function fillContent(): void {
|
|||
filteredResults = [];
|
||||
$(".pageAccount .history table tbody").empty();
|
||||
|
||||
let testNum = DB.getSnapshot()?.results?.length || 0;
|
||||
|
||||
DB.getSnapshot()?.results?.forEach(
|
||||
(result: MonkeyTypes.Result<MonkeyTypes.Mode>) => {
|
||||
// totalSeconds += tt;
|
||||
|
@ -601,7 +599,7 @@ function fillContent(): void {
|
|||
}
|
||||
|
||||
chartData.push({
|
||||
x: testNum,
|
||||
x: filteredResults.length,
|
||||
y: Config.alwaysShowCPM ? Misc.roundTo2(result.wpm * 5) : result.wpm,
|
||||
wpm: Config.alwaysShowCPM ? Misc.roundTo2(result.wpm * 5) : result.wpm,
|
||||
acc: result.acc,
|
||||
|
@ -620,13 +618,11 @@ function fillContent(): void {
|
|||
wpmChartData.push(result.wpm);
|
||||
|
||||
accChartData.push({
|
||||
x: testNum,
|
||||
x: filteredResults.length,
|
||||
y: result.acc,
|
||||
errorRate: 100 - result.acc,
|
||||
});
|
||||
|
||||
testNum--;
|
||||
|
||||
if (result.wpm > topWpm) {
|
||||
const puncsctring = result.punctuation ? ",<br>with punctuation" : "";
|
||||
const numbsctring = result.numbers
|
||||
|
@ -729,29 +725,23 @@ function fillContent(): void {
|
|||
}
|
||||
|
||||
if (chartData.length > 0) {
|
||||
chartData.reverse();
|
||||
accChartData.reverse();
|
||||
|
||||
// get pb points
|
||||
let currentPb = 0;
|
||||
const pb: { x: number; y: number }[] = [];
|
||||
|
||||
chartData.forEach((a) => {
|
||||
for (let i = chartData.length - 1; i >= 0; i--) {
|
||||
const a = chartData[i];
|
||||
if (a.y > currentPb) {
|
||||
currentPb = a.y;
|
||||
//todo: remove temporary fix
|
||||
// pb.push(a);
|
||||
pb.push(a);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// add last point to pb
|
||||
const xMax = chartData.length;
|
||||
|
||||
//todo: remove temporary fix
|
||||
// pb.push({
|
||||
// x: xMax,
|
||||
// y: pb[pb.length - 1].y,
|
||||
// });
|
||||
pb.push({
|
||||
x: 1,
|
||||
y: pb[pb.length - 1].y,
|
||||
});
|
||||
|
||||
const avgTen = [];
|
||||
const avgTenAcc = [];
|
||||
|
@ -759,43 +749,29 @@ function fillContent(): void {
|
|||
const avgHundredAcc = [];
|
||||
|
||||
for (let i = 0; i < chartData.length; i++) {
|
||||
// calculate 10 subset averages
|
||||
const startIdxTen = i < 10 ? 0 : i - 9;
|
||||
const subsetTen = chartData.slice(startIdxTen, i + 1);
|
||||
const accSubsetTen = accChartData.slice(startIdxTen, i + 1);
|
||||
// calculate averages of 10
|
||||
const subsetTen = chartData.slice(i, i + 10);
|
||||
const accSubsetTen = accChartData.slice(i, i + 10);
|
||||
const avgTenValue =
|
||||
subsetTen.reduce((acc, { y }) => acc + y, 0) / subsetTen.length;
|
||||
const accAvgTenValue =
|
||||
accSubsetTen.reduce((acc, { y }) => acc + y, 0) / subsetTen.length;
|
||||
accSubsetTen.reduce((acc, { y }) => acc + y, 0) / accSubsetTen.length;
|
||||
|
||||
// add values to arrays
|
||||
avgTen.push({ x: i + 1, y: avgTenValue });
|
||||
avgTenAcc.push({ x: i + 1, y: accAvgTenValue });
|
||||
|
||||
// calculate 100 subset averages
|
||||
const startIdxHundred = i < 100 ? 0 : i - 99;
|
||||
const subsetHundred = chartData.slice(startIdxHundred, i + 1);
|
||||
const accSubsetHundred = accChartData.slice(startIdxHundred, i + 1);
|
||||
// calculate averages of 100
|
||||
const subsetHundred = chartData.slice(i, i + 100);
|
||||
const accSubsetHundred = accChartData.slice(i, i + 100);
|
||||
const avgHundredValue =
|
||||
subsetHundred.reduce((acc, { y }) => acc + y, 0) / subsetHundred.length;
|
||||
const accAvgHundredValue =
|
||||
accSubsetHundred.reduce((acc, { y }) => acc + y, 0) /
|
||||
subsetHundred.length;
|
||||
|
||||
// add values to arrays
|
||||
accSubsetHundred.length;
|
||||
avgHundred.push({ x: i + 1, y: avgHundredValue });
|
||||
avgHundredAcc.push({ x: i + 1, y: accAvgHundredValue });
|
||||
}
|
||||
|
||||
//todo: remove temporary fix
|
||||
for (let i = 0; i < chartData.length; i++) {
|
||||
chartData[i].x = i + 1;
|
||||
}
|
||||
|
||||
for (let i = 0; i < accChartData.length; i++) {
|
||||
accChartData[i].x = i + 1;
|
||||
}
|
||||
|
||||
ChartController.accountHistory.data.datasets[0].data = chartData;
|
||||
ChartController.accountHistory.data.datasets[1].data = pb;
|
||||
ChartController.accountHistory.data.datasets[2].data = accChartData;
|
||||
|
@ -804,10 +780,7 @@ function fillContent(): void {
|
|||
ChartController.accountHistory.data.datasets[5].data = avgHundred;
|
||||
ChartController.accountHistory.data.datasets[6].data = avgHundredAcc;
|
||||
|
||||
accountHistoryScaleOptions["x"].max = xMax + 1;
|
||||
|
||||
chartData.reverse();
|
||||
accChartData.reverse();
|
||||
accountHistoryScaleOptions["x"].max = chartData.length + 1;
|
||||
}
|
||||
|
||||
const wpms = chartData.map((r) => r.y);
|
||||
|
|
|
@ -255,7 +255,14 @@ function updateWpmAndAcc(): void {
|
|||
}
|
||||
$("#result .stats .time .bottom .text").text(time);
|
||||
$("#result .stats .raw .bottom").removeAttr("aria-label");
|
||||
$("#result .stats .acc .bottom").removeAttr("aria-label");
|
||||
// $("#result .stats .acc .bottom").removeAttr("aria-label");
|
||||
|
||||
$("#result .stats .acc .bottom").attr(
|
||||
"aria-label",
|
||||
`${TestInput.accuracy.incorrect} mistake${
|
||||
TestInput.accuracy.incorrect == 1 ? "" : "s"
|
||||
}`
|
||||
);
|
||||
} else {
|
||||
//not showing decimal places
|
||||
if (Config.alwaysShowCPM == false) {
|
||||
|
@ -287,7 +294,12 @@ function updateWpmAndAcc(): void {
|
|||
}
|
||||
|
||||
$("#result .stats .acc .bottom").text(Math.floor(result.acc) + "%");
|
||||
$("#result .stats .acc .bottom").attr("aria-label", result.acc + "%");
|
||||
$("#result .stats .acc .bottom").attr(
|
||||
"aria-label",
|
||||
`${result.acc}% (${TestInput.accuracy.incorrect} mistake${
|
||||
TestInput.accuracy.incorrect == 1 ? "" : "s"
|
||||
})`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue