diff options
Diffstat (limited to 'src/db/DatabasePrint.cxx')
-rw-r--r-- | src/db/DatabasePrint.cxx | 48 |
1 files changed, 0 insertions, 48 deletions
diff --git a/src/db/DatabasePrint.cxx b/src/db/DatabasePrint.cxx index c65de373f..f6663311e 100644 --- a/src/db/DatabasePrint.cxx +++ b/src/db/DatabasePrint.cxx @@ -168,54 +168,6 @@ db_selection_print(Client &client, const DatabaseSelection &selection, return db->Visit(selection, d, s, p, error); } -struct SearchStats { - unsigned n_songs; - unsigned long total_time_s; -}; - -static void -PrintSearchStats(Client &client, const SearchStats &stats) -{ - client_printf(client, - "songs: %u\n" - "playtime: %lu\n", - stats.n_songs, stats.total_time_s); -} - -static bool -stats_visitor_song(SearchStats &stats, const LightSong &song) -{ - stats.n_songs++; - stats.total_time_s += song.GetDuration(); - - return true; -} - -bool -PrintSongCount(Client &client, const char *name, - const SongFilter *filter, - Error &error) -{ - const Database *db = client.GetDatabase(error); - if (db == nullptr) - return false; - - const DatabaseSelection selection(name, true, filter); - - SearchStats stats; - stats.n_songs = 0; - stats.total_time_s = 0; - - using namespace std::placeholders; - const auto f = std::bind(stats_visitor_song, std::ref(stats), - _1); - if (!db->Visit(selection, f, error)) - return false; - - PrintSearchStats(client, stats); - return true; -} - static bool PrintSongURIVisitor(Client &client, const LightSong &song) { |