From 6bf9d75807ecbec93145813d2f3a9169685b848a Mon Sep 17 00:00:00 2001 From: Alex Pletnev Date: Mon, 21 Dec 2015 08:49:03 +0200 Subject: [PATCH] #1750 TB feature/statistics issue Change time to read book formula to: ((total_read_time / read_pages) * (all_pages - current_page)) --- frontend/apps/reader/modules/readerfooter.lua | 3 ++- plugins/statistics.koplugin/main.lua | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/frontend/apps/reader/modules/readerfooter.lua b/frontend/apps/reader/modules/readerfooter.lua index 2bec2e4ec..7fc2e9a8a 100644 --- a/frontend/apps/reader/modules/readerfooter.lua +++ b/frontend/apps/reader/modules/readerfooter.lua @@ -230,7 +230,8 @@ function ReaderFooter:getProgressPercentage() end function ReaderFooter:getBookTimeToRead() - return self:getDataFromStatistics("TB: ", self.pages) + local current_page = self.view.document:getCurrentPage() + return self:getDataFromStatistics("TB: ", self.pages - current_page) end function ReaderFooter:getChapterTimeToRead() diff --git a/plugins/statistics.koplugin/main.lua b/plugins/statistics.koplugin/main.lua index a4bd18c27..9fc726934 100755 --- a/plugins/statistics.koplugin/main.lua +++ b/plugins/statistics.koplugin/main.lua @@ -236,10 +236,11 @@ function ReaderStatistics:updateCurrentStat() end local read_pages = util.tablelength(self.data.performance_in_pages) + local current_page = self.ui.document:getCurrentPage() local average_time_per_page = self.data.total_time_in_sec / read_pages table.insert(stats, { text = _("Current period"), mandatory = util.secondsToClock(self.current_period, false) }) - table.insert(stats, { text = _("Time to read"), mandatory = util.secondsToClock(self.data.pages * average_time_per_page, false) }) + table.insert(stats, { text = _("Time to read"), mandatory = util.secondsToClock((self.data.pages - current_page) * average_time_per_page, false) }) table.insert(stats, { text = _("Total time"), mandatory = util.secondsToClock(self.data.total_time_in_sec, false) }) table.insert(stats, { text = _("Total highlights"), mandatory = self.data.highlights }) table.insert(stats, { text = _("Total notes"), mandatory = self.data.notes })