Skip to content

Commit 9ab071d

Browse files
committed
Use page_stat instead of page_stat_data to get scaled page data
1 parent 5ee6748 commit 9ab071d

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "koshelf"
3-
version = "1.0.11"
3+
version = "1.0.12"
44
description = "Transform your KOReader library into a beautiful reading dashboard with statistics."
55
repository = "https://github.com/paviro/KOShelf"
66
license = "EUPL-1.2 license"

src/models.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,6 @@ pub struct PageStat {
353353
pub page: i64,
354354
pub start_time: i64,
355355
pub duration: i64,
356-
pub total_pages: i64,
357356
}
358357

359358
/// Main container for KoReader statistics data

src/statistics_parser.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,18 @@ impl StatisticsParser {
9090

9191
/// Parse page stat entries from the database
9292
fn parse_page_stats(conn: &Connection) -> Result<Vec<PageStat>> {
93-
let mut stmt = conn.prepare("SELECT id_book, page, start_time, duration, total_pages FROM page_stat_data")?;
93+
// Query the rescaled view so that page numbers are already expressed in the current
94+
// pagination of each document. The `page_stat` view has the same four columns we
95+
// actually use (id_book, page, start_time, duration). See KOReader's Lua code for
96+
// the precise definition.
97+
let mut stmt = conn.prepare("SELECT id_book, page, start_time, duration FROM page_stat")?;
9498

9599
let stat_iter = stmt.query_map([], |row| {
96100
Ok(PageStat {
97101
id_book: row.get(0)?,
98102
page: row.get(1)?,
99103
start_time: row.get(2)?,
100104
duration: row.get(3)?,
101-
total_pages: row.get(4)?,
102105
})
103106
})?;
104107

0 commit comments

Comments
 (0)