Created
August 14, 2020 12:13
-
-
Save lthms/11fbc5516cd234b485d5eb47b57dfc1b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn main() -> Result<()> { | |
let conn = kls::get_database().unwrap(); | |
kls::migrations::run_migrations(&conn).unwrap(); | |
for date in keyr::list_days()? { | |
let mut file = DayFile::open(&date, OpenOptions::new().read(true).clone())?; | |
file.read_global_count()?; | |
loop { | |
if let Some((key, count)) = file.read_entry(EntryLoc::Next)? { | |
let (h, _) = keyr::parse_key(&key).unwrap(); | |
kls::upsert_hour_count(&conn, date, h, count).unwrap(); | |
} else { | |
break; | |
} | |
} | |
} | |
println!("{}", kls::get_global_count(&conn).unwrap()); | |
println!("{}", kls::get_today_count(&conn).unwrap()); | |
Ok(()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment