From 807c4a256df8641128bf783ea0a9f07502b8c9bc Mon Sep 17 00:00:00 2001 From: Robert Date: Sat, 9 Sep 2017 20:18:16 +0200 Subject: [PATCH] Fix problem with import old .stat files (#3195) --- plugins/statistics.koplugin/main.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/statistics.koplugin/main.lua b/plugins/statistics.koplugin/main.lua index 8dedffb76..2780a2a39 100755 --- a/plugins/statistics.koplugin/main.lua +++ b/plugins/statistics.koplugin/main.lua @@ -294,6 +294,9 @@ function ReaderStatistics:addBookStatToDB(book_stats, conn) conn:exec('BEGIN') stmt = conn:prepare("INSERT OR IGNORE INTO page_stat VALUES(?, ?, ?, ?)") local avg_time = math.ceil(book_stats.total_time_in_sec / read_pages) + if avg_time > self.page_max_read_sec then + avg_time = self.page_max_read_sec + end local first_read_page = book_stats.performance_in_pages[sorted_performance[1]] if first_read_page > 1 then first_read_page = first_read_page - 1 @@ -367,7 +370,7 @@ function ReaderStatistics:migrateToDB(conn) if lfs.attributes(path, "mode") == "file" then local old_data = self:importFromFile(statistics_dir, curr_file) if old_data and old_data.total_time > 0 and not exclude_titles[old_data.title] then - local book_stats = {} + local book_stats = { performance_in_pages= {} } for _, v in pairs(old_data.details) do book_stats.performance_in_pages[v.time] = v.page end @@ -378,6 +381,7 @@ function ReaderStatistics:migrateToDB(conn) book_stats.pages = old_data.pages book_stats.series = old_data.series book_stats.language = old_data.language + book_stats.total_time_in_sec = old_data.total_time book_stats.file = nil if self:addBookStatToDB(book_stats, conn) then nr_of_conv_books = nr_of_conv_books + 1