diff --git a/Overlay.qml b/Overlay.qml index c69bb35..c19c02a 100644 --- a/Overlay.qml +++ b/Overlay.qml @@ -383,7 +383,7 @@ Item { targetErrors: Model.drillTargetErrors(root.challenge, root.keyMistakes, root.bigramMistakes), characters: root.correctChars, wpm: finalWpm, - rawWpm: Model.rawWordsPerMinute(root.totalKeypresses, root.elapsedMs), + rawWpm: Model.wordsPerMinute(root.totalKeypresses, root.elapsedMs), accuracy: Model.accuracy(root.totalKeypresses, root.incorrectKeypresses), consistency: Model.consistency(root.paceSamples), errors: root.incorrectKeypresses, diff --git a/TypearchyModel.js b/TypearchyModel.js index 9f9f33c..f88e838 100644 --- a/TypearchyModel.js +++ b/TypearchyModel.js @@ -77,14 +77,9 @@ function advanceLineBreaks(mode, prompt, typed, character) { return next } -function wordsPerMinute(correctChars, elapsedMs) { +function wordsPerMinute(characters, elapsedMs) { if (!(elapsedMs > 0)) return 0 - return round((correctChars / 5) / (elapsedMs / 60000), 1) -} - -function rawWordsPerMinute(keypresses, elapsedMs) { - if (!(elapsedMs > 0)) return 0 - return round((keypresses / 5) / (elapsedMs / 60000), 1) + return round((characters / 5) / (elapsedMs / 60000), 1) } function accuracy(keypresses, incorrectKeypresses) { diff --git a/tests/model.test.mjs b/tests/model.test.mjs index b59f7ff..c0025b9 100644 --- a/tests/model.test.mjs +++ b/tests/model.test.mjs @@ -150,7 +150,7 @@ assert.match(model.renderedPrompt("one\ntwo", "one\u0001", { normal: "#ffffff", dim: "#777777", error: "#ff0000", cursor: "#ffffff", background: "#000000" }), /color:#ffffff/) assert.equal(model.wordsPerMinute(150, 30000), 60) -assert.equal(model.rawWordsPerMinute(175, 30000), 70) +assert.equal(model.wordsPerMinute(175, 30000), 70) assert.equal(model.accuracy(100, 3), 97) assert.equal(model.consistency([60, 60, 60]), 100) assert.equal(model.eraseWordIndex("one two"), 4) diff --git a/website/db/schema.ts b/website/db/schema.ts deleted file mode 100644 index d32f51e..0000000 --- a/website/db/schema.ts +++ /dev/null @@ -1,61 +0,0 @@ -export const schemaStatements = [ - `CREATE TABLE IF NOT EXISTS profiles ( - id TEXT PRIMARY KEY, - handle TEXT NOT NULL UNIQUE COLLATE NOCASE, - recovery_hash TEXT NOT NULL, - visibility TEXT NOT NULL DEFAULT 'public' CHECK (visibility IN ('public', 'private')), - created_at INTEGER NOT NULL, - updated_at INTEGER NOT NULL - )`, - `CREATE TABLE IF NOT EXISTS devices ( - id TEXT PRIMARY KEY, - profile_id TEXT NOT NULL REFERENCES profiles(id) ON DELETE CASCADE, - token_hash TEXT NOT NULL UNIQUE, - label TEXT NOT NULL, - created_at INTEGER NOT NULL, - last_used_at INTEGER NOT NULL, - revoked_at INTEGER - )`, - `CREATE TABLE IF NOT EXISTS connections ( - code TEXT PRIMARY KEY, - token_hash TEXT NOT NULL UNIQUE, - kind TEXT NOT NULL DEFAULT 'connect', - label TEXT NOT NULL, - profile_id TEXT REFERENCES profiles(id) ON DELETE CASCADE, - created_at INTEGER NOT NULL, - expires_at INTEGER NOT NULL, - claimed_at INTEGER - )`, - `CREATE TABLE IF NOT EXISTS runs ( - id TEXT PRIMARY KEY, - slug TEXT NOT NULL UNIQUE, - profile_id TEXT NOT NULL REFERENCES profiles(id) ON DELETE CASCADE, - schema_version INTEGER NOT NULL, - content_version TEXT NOT NULL, - mode TEXT NOT NULL, - challenge_key TEXT NOT NULL, - target TEXT NOT NULL, - duration INTEGER NOT NULL, - wpm REAL NOT NULL, - raw_wpm REAL NOT NULL, - accuracy REAL NOT NULL, - consistency REAL NOT NULL, - errors INTEGER NOT NULL, - pace_json TEXT NOT NULL, - created_at INTEGER NOT NULL, - pinned_at INTEGER - )`, - `CREATE TABLE IF NOT EXISTS rate_limits ( - key TEXT PRIMARY KEY, - count INTEGER NOT NULL, - reset_at INTEGER NOT NULL - )`, - `CREATE INDEX IF NOT EXISTS idx_devices_profile_active - ON devices(profile_id, revoked_at)`, - `CREATE INDEX IF NOT EXISTS idx_connections_expires - ON connections(expires_at)`, - `CREATE INDEX IF NOT EXISTS idx_runs_profile_created - ON runs(profile_id, created_at DESC)`, - `CREATE INDEX IF NOT EXISTS idx_runs_profile_pinned - ON runs(profile_id, pinned_at DESC) WHERE pinned_at IS NOT NULL`, -];