mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2026-01-02 21:44:06 +08:00
added filter debugging to find a bug
This commit is contained in:
parent
97c703fe47
commit
5d17aede51
3 changed files with 81 additions and 28 deletions
|
|
@ -19,6 +19,15 @@ import * as ThemePicker from "./theme-picker";
|
|||
import * as AllTimeStats from "./all-time-stats";
|
||||
import * as PbTables from "./pb-tables";
|
||||
|
||||
let filterDebug = false;
|
||||
//toggle filterdebug
|
||||
export function toggleFilterDebug() {
|
||||
filterDebug = !filterDebug;
|
||||
if (filterDebug) {
|
||||
console.log("filterDebug is on");
|
||||
}
|
||||
}
|
||||
|
||||
export function getDataAndInit() {
|
||||
DB.initSnapshot()
|
||||
.then(async (e) => {
|
||||
|
|
@ -369,21 +378,37 @@ export function update() {
|
|||
if (resdiff == undefined) {
|
||||
resdiff = "normal";
|
||||
}
|
||||
if (!ResultFilters.getFilter("difficulty", resdiff)) return;
|
||||
if (!ResultFilters.getFilter("mode", result.mode)) return;
|
||||
if (!ResultFilters.getFilter("difficulty", resdiff)) {
|
||||
if (filterDebug)
|
||||
console.log(`skipping result due to difficulty filter`, result);
|
||||
return;
|
||||
}
|
||||
if (!ResultFilters.getFilter("mode", result.mode)) {
|
||||
if (filterDebug)
|
||||
console.log(`skipping result due to mode filter`, result);
|
||||
return;
|
||||
}
|
||||
|
||||
if (result.mode == "time") {
|
||||
let timefilter = "custom";
|
||||
if ([15, 30, 60, 120].includes(parseInt(result.mode2))) {
|
||||
timefilter = result.mode2;
|
||||
}
|
||||
if (!ResultFilters.getFilter("time", timefilter)) return;
|
||||
if (!ResultFilters.getFilter("time", timefilter)) {
|
||||
if (filterDebug)
|
||||
console.log(`skipping result due to time filter`, result);
|
||||
return;
|
||||
}
|
||||
} else if (result.mode == "words") {
|
||||
let wordfilter = "custom";
|
||||
if ([10, 25, 50, 100, 200].includes(parseInt(result.mode2))) {
|
||||
wordfilter = result.mode2;
|
||||
}
|
||||
if (!ResultFilters.getFilter("words", wordfilter)) return;
|
||||
if (!ResultFilters.getFilter("words", wordfilter)) {
|
||||
if (filterDebug)
|
||||
console.log(`skipping result due to word filter`, result);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (result.quoteLength != null) {
|
||||
|
|
@ -400,8 +425,11 @@ export function update() {
|
|||
if (
|
||||
filter !== null &&
|
||||
!ResultFilters.getFilter("quoteLength", filter)
|
||||
)
|
||||
) {
|
||||
if (filterDebug)
|
||||
console.log(`skipping result due to quoteLength filter`, result);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
let langFilter = ResultFilters.getFilter(
|
||||
|
|
@ -415,24 +443,44 @@ export function update() {
|
|||
) {
|
||||
langFilter = true;
|
||||
}
|
||||
if (!langFilter) return;
|
||||
if (!langFilter) {
|
||||
if (filterDebug)
|
||||
console.log(`skipping result due to language filter`, result);
|
||||
return;
|
||||
}
|
||||
|
||||
let puncfilter = "off";
|
||||
if (result.punctuation) {
|
||||
puncfilter = "on";
|
||||
}
|
||||
if (!ResultFilters.getFilter("punctuation", puncfilter)) return;
|
||||
if (!ResultFilters.getFilter("punctuation", puncfilter)) {
|
||||
if (filterDebug)
|
||||
console.log(`skipping result due to punctuation filter`, result);
|
||||
return;
|
||||
}
|
||||
|
||||
let numfilter = "off";
|
||||
if (result.numbers) {
|
||||
numfilter = "on";
|
||||
}
|
||||
if (!ResultFilters.getFilter("numbers", numfilter)) return;
|
||||
if (!ResultFilters.getFilter("numbers", numfilter)) {
|
||||
if (filterDebug)
|
||||
console.log(`skipping result due to numbers filter`, result);
|
||||
return;
|
||||
}
|
||||
|
||||
if (result.funbox === "none" || result.funbox === undefined) {
|
||||
if (!ResultFilters.getFilter("funbox", "none")) return;
|
||||
if (!ResultFilters.getFilter("funbox", "none")) {
|
||||
if (filterDebug)
|
||||
console.log(`skipping result due to funbox filter`, result);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (!ResultFilters.getFilter("funbox", result.funbox)) return;
|
||||
if (!ResultFilters.getFilter("funbox", result.funbox)) {
|
||||
if (filterDebug)
|
||||
console.log(`skipping result due to funbox filter`, result);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
let tagHide = true;
|
||||
|
|
@ -461,7 +509,11 @@ export function update() {
|
|||
});
|
||||
}
|
||||
|
||||
if (tagHide) return;
|
||||
if (tagHide) {
|
||||
if (filterDebug)
|
||||
console.log(`skipping result due to tag filter`, result);
|
||||
return;
|
||||
}
|
||||
|
||||
let timeSinceTest = Math.abs(result.timestamp - Date.now()) / 1000;
|
||||
|
||||
|
|
@ -479,7 +531,11 @@ export function update() {
|
|||
datehide = false;
|
||||
}
|
||||
|
||||
if (datehide) return;
|
||||
if (datehide) {
|
||||
if (filterDebug)
|
||||
console.log(`skipping result due to date filter`, result);
|
||||
return;
|
||||
}
|
||||
|
||||
filteredResults.push(result);
|
||||
} catch (e) {
|
||||
|
|
|
|||
|
|
@ -16,18 +16,14 @@ global.filters = ResultFilters.getFilters();
|
|||
global.glarsesMode = toggleGlarses;
|
||||
|
||||
global.crownTest = async () => {
|
||||
console.log('local pb', await DB.getLocalPB(
|
||||
"time",
|
||||
60,
|
||||
false,
|
||||
"english",
|
||||
"normal"
|
||||
))
|
||||
console.log('local highest wpm', await DB.getUserHighestWpm(
|
||||
"time",
|
||||
60,
|
||||
false,
|
||||
"english",
|
||||
"normal"
|
||||
))
|
||||
}
|
||||
console.log(
|
||||
"local pb",
|
||||
await DB.getLocalPB("time", 60, false, "english", "normal")
|
||||
);
|
||||
console.log(
|
||||
"local highest wpm",
|
||||
await DB.getUserHighestWpm("time", 60, false, "english", "normal")
|
||||
);
|
||||
};
|
||||
|
||||
global.filterDebug = Account.toggleFilterDebug;
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import * as ResultFilters from "./result-filters";
|
|||
import Config from "./config";
|
||||
import * as SimplePopups from "./simple-popups";
|
||||
import * as AccountController from "./account-controller";
|
||||
import {toggleGlarses} from "./test-logic";
|
||||
import { toggleGlarses } from "./test-logic";
|
||||
import "./caps-warning";
|
||||
import "./support-popup";
|
||||
import "./version-popup";
|
||||
|
|
@ -22,3 +22,4 @@ import "./import-settings-popup";
|
|||
import "./input-controller";
|
||||
import "./ready";
|
||||
import "./about-page";
|
||||
import * as Account from "./account";
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue