Commit 7cfe929c authored by Max Kellermann's avatar Max Kellermann

db/Count: print empty group if song without grouped tag exists

Be consistent with "list" responses.
parent 6c06244e
ver 0.20.22 (not yet released) ver 0.20.22 (not yet released)
* protocol * protocol
- add tag fallbacks for AlbumArtistSort, ArtistSort - add tag fallbacks for AlbumArtistSort, ArtistSort
- "count group ..." can print an empty group
* storage * storage
- curl: URL-encode paths - curl: URL-encode paths
* Android * Android
......
...@@ -1599,6 +1599,11 @@ OK ...@@ -1599,6 +1599,11 @@ OK
per-artist counts: per-artist counts:
</para> </para>
<programlisting>count group artist</programlisting> <programlisting>count group artist</programlisting>
<para>
A group with an empty value contains counts of matching
song which don't this group tag. It exists only if at
least one such song is found.
</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
......
...@@ -90,10 +90,10 @@ GroupCountVisitor(TagCountMap &map, TagType group, const LightSong &song) ...@@ -90,10 +90,10 @@ GroupCountVisitor(TagCountMap &map, TagType group, const LightSong &song)
assert(song.tag != nullptr); assert(song.tag != nullptr);
const Tag &tag = *song.tag; const Tag &tag = *song.tag;
VisitTagWithFallback(tag, group, VisitTagWithFallbackOrEmpty(tag, group,
std::bind(CollectGroupCounts, std::ref(map), std::bind(CollectGroupCounts, std::ref(map),
std::cref(tag), std::cref(tag),
std::placeholders::_1)); std::placeholders::_1));
} }
void void
......
...@@ -49,4 +49,12 @@ VisitTagWithFallback(const Tag &tag, TagType type, F &&f) noexcept ...@@ -49,4 +49,12 @@ VisitTagWithFallback(const Tag &tag, TagType type, F &&f) noexcept
}); });
} }
template<typename F>
void
VisitTagWithFallbackOrEmpty(const Tag &tag, TagType type, F &&f) noexcept
{
if (!VisitTagWithFallback(tag, type, f))
f("");
}
#endif #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment