From a7652523258056543133078bbbe6aaac3f4ddbe6 Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Thu, 11 Nov 2021 20:12:03 +0000 Subject: [PATCH] show counts of available songs/albums/artist for now in log_level=debug --- bin/mpd-feeder | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/bin/mpd-feeder b/bin/mpd-feeder index 8644dde..04da38f 100755 --- a/bin/mpd-feeder +++ b/bin/mpd-feeder @@ -357,6 +357,93 @@ SQL } undef $sth; + if (scalar(@result) == $num and $log->is_debug) { + $sql =~ s/^SELECT .+$/SELECT COUNT(DISTINCT s.path)/m; + $sql =~ s/^ORDER BY .+$//m; + $sql =~ s/^LIMIT .+$//m; + $log->debug($sql); + my $sth = $db->prepare_cached($sql); + pop @params; + $sth->execute(@params); + my $count = ($sth->fetchrow_array)[0]; + $sth->finish; + + $sth = $db->prepare_cached('SELECT COUNT(*) FROM songs'); + $sth->execute; + my $total = ($sth->fetchrow_array)[0]; + $log->debug( + sprintf( + "Number of songs meeting the criteria: %d out of total %d (%5.2f%%)", + $count, $total, 100.0 * $count / $total + ) + ); + $sth->finish; + + $sql = <prepare_cached($sql); + $sth->execute($opt->min_song_interval); + $count = ($sth->fetchrow_array)[0]; + $total = ($sth->fetchrow_array)[0]; + $sth->finish; + + $log->debug( + sprintf( + "Number of songs not queued soon: %d out of total %d (%5.2f%%)", + $count, $total, 100.0 * $count / $total + ) + ); + $sth->finish; + + $sql = <prepare_cached($sql); + $sth->execute($opt->min_artist_interval); + $count = ($sth->fetchrow_array)[0]; + $total = ($sth->fetchrow_array)[0]; + $log->debug( + sprintf( + "Number of artists not queued soon: %d out of total %d (%5.2f%%)", + $count, $total, 100.0 * $count / $total + ) + ); + $sth->finish; + + $sql = <prepare_cached($sql); + $sth->execute($opt->min_album_interval); + $count = ($sth->fetchrow_array)[0]; + $total = ($sth->fetchrow_array)[0]; + $log->debug( + sprintf( + "Number of albums not queued soon: %d out of total %d (%5.2f%%)", + $count, $total, 100.0 * $count / $total + ) + ); + $sth->finish; + + undef $sth; + } + return @result; } -- 2.39.2