Skip to content

Commit

Permalink
Log the number of imported listens
Browse files Browse the repository at this point in the history
At first I wanted to have this temporarily to verify whether the
incremental import works, but it's actually nice to have, and the output
of my "count" subcommand is already polluted with other logs, so I might
as well make the importer log this one line.
  • Loading branch information
ruuda committed May 19, 2024
1 parent b5b6746 commit d6f5760
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/playcount.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,12 +416,15 @@ impl PlayCounter {
tx: &mut Transaction,
) -> database::Result<()> {
let start_second = self.last_counted_at.to_posix_timestamp();
let mut n = 0;
for listen_opt in database::iter_listens_since(tx, start_second)? {
let listen = listen_opt?;
let at = Instant::from_posix_timestamp(listen.started_at_second);
let track_id = TrackId(listen.track_id as u64);
self.count(index, at.into(), track_id);
n += 1;
}
println!("Imported {n} new listens from database.");
Ok(())
}

Expand Down

0 comments on commit d6f5760

Please sign in to comment.