Skip to content

Instantly share code, notes, and snippets.

@lthms
Created August 14, 2020 12:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lthms/11fbc5516cd234b485d5eb47b57dfc1b to your computer and use it in GitHub Desktop.
Save lthms/11fbc5516cd234b485d5eb47b57dfc1b to your computer and use it in GitHub Desktop.
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