DatabasePrint: refactor variable/function names
This commit is contained in:
@@ -159,7 +159,7 @@ handle_count(Client &client, int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
Error error;
|
Error error;
|
||||||
return searchStatsForSongsIn(client, "", &filter, error)
|
return PrintSongCount(client, "", &filter, error)
|
||||||
? CommandResult::OK
|
? CommandResult::OK
|
||||||
: print_error(client, error);
|
: print_error(client, error);
|
||||||
}
|
}
|
||||||
@@ -243,7 +243,7 @@ handle_list(Client &client, int argc, char *argv[])
|
|||||||
|
|
||||||
Error error;
|
Error error;
|
||||||
CommandResult ret =
|
CommandResult ret =
|
||||||
listAllUniqueTags(client, tagType, group_mask, filter, error)
|
PrintUniqueTags(client, tagType, group_mask, filter, error)
|
||||||
? CommandResult::OK
|
? CommandResult::OK
|
||||||
: print_error(client, error);
|
: print_error(client, error);
|
||||||
|
|
||||||
|
@@ -169,30 +169,30 @@ db_selection_print(Client &client, const DatabaseSelection &selection,
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct SearchStats {
|
struct SearchStats {
|
||||||
unsigned numberOfSongs;
|
unsigned n_songs;
|
||||||
unsigned long playTime;
|
unsigned long total_time_s;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
printSearchStats(Client &client, const SearchStats &stats)
|
PrintSearchStats(Client &client, const SearchStats &stats)
|
||||||
{
|
{
|
||||||
client_printf(client,
|
client_printf(client,
|
||||||
"songs: %u\n"
|
"songs: %u\n"
|
||||||
"playtime: %lu\n",
|
"playtime: %lu\n",
|
||||||
stats.numberOfSongs, stats.playTime);
|
stats.n_songs, stats.total_time_s);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
stats_visitor_song(SearchStats &stats, const LightSong &song)
|
stats_visitor_song(SearchStats &stats, const LightSong &song)
|
||||||
{
|
{
|
||||||
stats.numberOfSongs++;
|
stats.n_songs++;
|
||||||
stats.playTime += song.GetDuration();
|
stats.total_time_s += song.GetDuration();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
searchStatsForSongsIn(Client &client, const char *name,
|
PrintSongCount(Client &client, const char *name,
|
||||||
const SongFilter *filter,
|
const SongFilter *filter,
|
||||||
Error &error)
|
Error &error)
|
||||||
{
|
{
|
||||||
@@ -203,8 +203,8 @@ searchStatsForSongsIn(Client &client, const char *name,
|
|||||||
const DatabaseSelection selection(name, true, filter);
|
const DatabaseSelection selection(name, true, filter);
|
||||||
|
|
||||||
SearchStats stats;
|
SearchStats stats;
|
||||||
stats.numberOfSongs = 0;
|
stats.n_songs = 0;
|
||||||
stats.playTime = 0;
|
stats.total_time_s = 0;
|
||||||
|
|
||||||
using namespace std::placeholders;
|
using namespace std::placeholders;
|
||||||
const auto f = std::bind(stats_visitor_song, std::ref(stats),
|
const auto f = std::bind(stats_visitor_song, std::ref(stats),
|
||||||
@@ -212,7 +212,7 @@ searchStatsForSongsIn(Client &client, const char *name,
|
|||||||
if (!db->Visit(selection, f, error))
|
if (!db->Visit(selection, f, error))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
printSearchStats(client, stats);
|
PrintSearchStats(client, stats);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -243,7 +243,7 @@ PrintUniqueTag(Client &client, TagType tag_type,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
listAllUniqueTags(Client &client, unsigned type, uint32_t group_mask,
|
PrintUniqueTags(Client &client, unsigned type, uint32_t group_mask,
|
||||||
const SongFilter *filter,
|
const SongFilter *filter,
|
||||||
Error &error)
|
Error &error)
|
||||||
{
|
{
|
||||||
|
@@ -39,12 +39,12 @@ db_selection_print(Client &client, const DatabaseSelection &selection,
|
|||||||
|
|
||||||
gcc_nonnull(2)
|
gcc_nonnull(2)
|
||||||
bool
|
bool
|
||||||
searchStatsForSongsIn(Client &client, const char *name,
|
PrintSongCount(Client &client, const char *name,
|
||||||
const SongFilter *filter,
|
const SongFilter *filter,
|
||||||
Error &error);
|
Error &error);
|
||||||
|
|
||||||
bool
|
bool
|
||||||
listAllUniqueTags(Client &client, unsigned type, uint32_t group_mask,
|
PrintUniqueTags(Client &client, unsigned type, uint32_t group_mask,
|
||||||
const SongFilter *filter,
|
const SongFilter *filter,
|
||||||
Error &error);
|
Error &error);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user