When max similarity count is set to 0, return nothing instead of everything
This commit is contained in:
@@ -36,25 +36,26 @@ std::unique_ptr<IEngine> createClustersEngine(Db& db)
|
||||
return std::make_unique<ClusterEngine>(db);
|
||||
}
|
||||
|
||||
TrackContainer
|
||||
ClusterEngine::findSimilarTracks(const std::vector<TrackId>& trackIds, std::size_t maxCount) const
|
||||
TrackContainer ClusterEngine::findSimilarTracks(const std::vector<TrackId>& trackIds, std::size_t maxCount) const
|
||||
{
|
||||
Session& dbSession {_db.getTLSSession()};
|
||||
if (maxCount == 0)
|
||||
return {};
|
||||
|
||||
Session& dbSession{ _db.getTLSSession() };
|
||||
auto transaction{ dbSession.createSharedTransaction() };
|
||||
|
||||
const auto similarTrackIds{ Track::findSimilarTracks(dbSession, trackIds, Range {0, maxCount}) };
|
||||
return std::move(similarTrackIds.results);
|
||||
}
|
||||
|
||||
TrackContainer
|
||||
ClusterEngine::findSimilarTracksFromTrackList(TrackListId tracklistId, std::size_t maxCount) const
|
||||
TrackContainer ClusterEngine::findSimilarTracksFromTrackList(TrackListId tracklistId, std::size_t maxCount) const
|
||||
{
|
||||
TrackContainer res;
|
||||
if (maxCount == 0)
|
||||
return res;
|
||||
|
||||
{
|
||||
Session& dbSession{ _db.getTLSSession() };
|
||||
|
||||
TrackContainer res;
|
||||
|
||||
{
|
||||
auto transaction{ dbSession.createSharedTransaction() };
|
||||
|
||||
const TrackList::pointer trackList{ TrackList::find(dbSession, tracklistId) };
|
||||
@@ -69,13 +70,14 @@ ClusterEngine::findSimilarTracksFromTrackList(TrackListId tracklistId, std::size
|
||||
return res;
|
||||
}
|
||||
|
||||
ReleaseContainer
|
||||
ClusterEngine::getSimilarReleases(ReleaseId releaseId, std::size_t maxCount) const
|
||||
ReleaseContainer ClusterEngine::getSimilarReleases(ReleaseId releaseId, std::size_t maxCount) const
|
||||
{
|
||||
ReleaseContainer res;
|
||||
if (maxCount == 0)
|
||||
return res;
|
||||
|
||||
{
|
||||
Session& dbSession{ _db.getTLSSession() };
|
||||
|
||||
ReleaseContainer res;
|
||||
{
|
||||
auto transaction{ dbSession.createSharedTransaction() };
|
||||
|
||||
auto release{ Release::find(dbSession, releaseId) };
|
||||
@@ -90,11 +92,12 @@ ClusterEngine::getSimilarReleases(ReleaseId releaseId, std::size_t maxCount) con
|
||||
return res;
|
||||
}
|
||||
|
||||
ArtistContainer
|
||||
ClusterEngine::getSimilarArtists(ArtistId artistId, EnumSet<TrackArtistLinkType> artistLinkTypes, std::size_t maxCount) const
|
||||
ArtistContainer ClusterEngine::getSimilarArtists(ArtistId artistId, EnumSet<TrackArtistLinkType> artistLinkTypes, std::size_t maxCount) const
|
||||
{
|
||||
Session& dbSession {_db.getTLSSession()};
|
||||
if (maxCount == 0)
|
||||
return {};
|
||||
|
||||
Session& dbSession{ _db.getTLSSession() };
|
||||
auto transaction{ dbSession.createSharedTransaction() };
|
||||
|
||||
auto artist{ Artist::find(dbSession, artistId) };
|
||||
|
||||
Reference in New Issue
Block a user