Bring more diversity in the radio mode. fixes #54

This commit is contained in:
emeric
2022-10-19 13:56:32 +02:00
parent b85553af34
commit c816b0db45
21 changed files with 750 additions and 104 deletions
+28
View File
@@ -520,5 +520,33 @@ Track::getClusterGroups(const std::vector<ClusterType::pointer>& clusterTypes, s
return res;
}
namespace Debug
{
std::ostream&
operator<<(std::ostream& os, const TrackInfo& trackInfo)
{
auto transaction {trackInfo.session.createSharedTransaction()};
const Track::pointer track {Track::find(trackInfo.session, trackInfo.trackId)};
if (track)
{
os << track->getName();
if (const Release::pointer release {track->getRelease()})
os << " [" << release->getName() << "]";
for (auto artist : track->getArtists({TrackArtistLinkType::Artist}))
os << " - " << artist->getName();
for (auto cluster : track->getClusters())
os << " {" + cluster->getType()->getName() << "-" << cluster->getName() << "}";
}
else
{
os << "*unknown*";
}
return os;
}
}
} // namespace Database
@@ -21,10 +21,12 @@
#include <chrono>
#include <filesystem>
#include <iostream>
#include <optional>
#include <string>
#include <string_view>
#include <unordered_set>
#include <utility>
#include <vector>
#include <Wt/WDateTime.h>
@@ -163,8 +165,8 @@ class Track : public Object<Track, TrackId>
std::optional<float> getReleaseReplayGain() const { return _releaseReplayGain; }
// no artistLinkTypes means get all
std::vector<ObjectPtr<Artist>> getArtists(EnumSet<TrackArtistLinkType> artistLinkTypes) const;
std::vector<ArtistId> getArtistIds(EnumSet<TrackArtistLinkType> artistLinkTypes) const;
std::vector<ObjectPtr<Artist>> getArtists(EnumSet<TrackArtistLinkType> artistLinkTypes) const; // no type means all
std::vector<ArtistId> getArtistIds(EnumSet<TrackArtistLinkType> artistLinkTypes) const; // no type means all
std::vector<ObjectPtr<TrackArtistLink>> getArtistLinks() const;
ObjectPtr<Release> getRelease() const { return _release; }
std::vector<ObjectPtr<Cluster>> getClusters() const;
@@ -237,6 +239,16 @@ class Track : public Object<Track, TrackId>
Wt::Dbo::collection<Wt::Dbo::ptr<Cluster>> _clusters;
};
namespace Debug
{
struct TrackInfo
{
Session& session;
TrackId trackId;
};
std::ostream& operator<<(std::ostream& os, const TrackInfo& trackInfo);
}
} // namespace database