[fix] 0 page issue, [add] wpm logging
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Evan Reichard 2023-10-31 17:30:42 -04:00
parent d27b9061bb
commit 5f1de4ec67

View File

@ -724,15 +724,24 @@ class EBookReader {
this.bookState.currentWord += pageWords; this.bookState.currentWord += pageWords;
let pageWPM = pageWords / (elapsedTime / 60000); let pageWPM = pageWords / (elapsedTime / 60000);
console.log("[createActivity] Page WPM:", pageWPM);
// Exclude Ridiculous WPM // 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 // Ensure WPM Minimum
if (pageWPM < WPM_MIN) elapsedTime = (pageWords / WPM_MIN) * 60000; if (pageWPM < WPM_MIN) elapsedTime = (pageWords / WPM_MIN) * 60000;
let totalPages = Math.round(1 / percentRead); let totalPages = Math.round(1 / percentRead);
// Exclude 0 Pages
if (totalPages == 0)
return console.log("[createActivity] Invalid Total Pages (0)");
let currentPage = Math.round( let currentPage = Math.round(
(startingWord * totalPages) / this.bookState.words (startingWord * totalPages) / this.bookState.words
); );