From 5f1de4ec676723592e2dfdc95b179ea55f53a5f8 Mon Sep 17 00:00:00 2001 From: Evan Reichard Date: Tue, 31 Oct 2023 17:30:42 -0400 Subject: [PATCH] [fix] 0 page issue, [add] wpm logging --- assets/reader/index.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/assets/reader/index.js b/assets/reader/index.js index 37df536..c220738 100644 --- a/assets/reader/index.js +++ b/assets/reader/index.js @@ -724,15 +724,24 @@ class EBookReader { this.bookState.currentWord += pageWords; let pageWPM = pageWords / (elapsedTime / 60000); + console.log("[createActivity] Page WPM:", pageWPM); // Exclude Ridiculous WPM - // if (pageWPM >= WPM_MAX) return; + if (pageWPM >= WPM_MAX) + return console.log( + "[createActivity] Page WPM Exceeds Max (2000):", + pageWPM + ); // Ensure WPM Minimum if (pageWPM < WPM_MIN) elapsedTime = (pageWords / WPM_MIN) * 60000; let totalPages = Math.round(1 / percentRead); + // Exclude 0 Pages + if (totalPages == 0) + return console.log("[createActivity] Invalid Total Pages (0)"); + let currentPage = Math.round( (startingWord * totalPages) / this.bookState.words );