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);
|
return std::make_unique<ClusterEngine>(db);
|
||||||
}
|
}
|
||||||
|
|
||||||
TrackContainer
|
TrackContainer ClusterEngine::findSimilarTracks(const std::vector<TrackId>& trackIds, std::size_t maxCount) const
|
||||||
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() };
|
auto transaction{ dbSession.createSharedTransaction() };
|
||||||
|
|
||||||
const auto similarTrackIds{ Track::findSimilarTracks(dbSession, trackIds, Range {0, maxCount}) };
|
const auto similarTrackIds{ Track::findSimilarTracks(dbSession, trackIds, Range {0, maxCount}) };
|
||||||
return std::move(similarTrackIds.results);
|
return std::move(similarTrackIds.results);
|
||||||
}
|
}
|
||||||
|
|
||||||
TrackContainer
|
TrackContainer ClusterEngine::findSimilarTracksFromTrackList(TrackListId tracklistId, std::size_t maxCount) const
|
||||||
ClusterEngine::findSimilarTracksFromTrackList(TrackListId tracklistId, std::size_t maxCount) const
|
{
|
||||||
|
TrackContainer res;
|
||||||
|
if (maxCount == 0)
|
||||||
|
return res;
|
||||||
|
|
||||||
{
|
{
|
||||||
Session& dbSession{ _db.getTLSSession() };
|
Session& dbSession{ _db.getTLSSession() };
|
||||||
|
|
||||||
TrackContainer res;
|
|
||||||
|
|
||||||
{
|
|
||||||
auto transaction{ dbSession.createSharedTransaction() };
|
auto transaction{ dbSession.createSharedTransaction() };
|
||||||
|
|
||||||
const TrackList::pointer trackList{ TrackList::find(dbSession, tracklistId) };
|
const TrackList::pointer trackList{ TrackList::find(dbSession, tracklistId) };
|
||||||
@@ -69,13 +70,14 @@ ClusterEngine::findSimilarTracksFromTrackList(TrackListId tracklistId, std::size
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReleaseContainer
|
ReleaseContainer ClusterEngine::getSimilarReleases(ReleaseId releaseId, std::size_t maxCount) const
|
||||||
ClusterEngine::getSimilarReleases(ReleaseId releaseId, std::size_t maxCount) const
|
{
|
||||||
|
ReleaseContainer res;
|
||||||
|
if (maxCount == 0)
|
||||||
|
return res;
|
||||||
|
|
||||||
{
|
{
|
||||||
Session& dbSession{ _db.getTLSSession() };
|
Session& dbSession{ _db.getTLSSession() };
|
||||||
|
|
||||||
ReleaseContainer res;
|
|
||||||
{
|
|
||||||
auto transaction{ dbSession.createSharedTransaction() };
|
auto transaction{ dbSession.createSharedTransaction() };
|
||||||
|
|
||||||
auto release{ Release::find(dbSession, releaseId) };
|
auto release{ Release::find(dbSession, releaseId) };
|
||||||
@@ -90,11 +92,12 @@ ClusterEngine::getSimilarReleases(ReleaseId releaseId, std::size_t maxCount) con
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
ArtistContainer
|
ArtistContainer ClusterEngine::getSimilarArtists(ArtistId artistId, EnumSet<TrackArtistLinkType> artistLinkTypes, std::size_t maxCount) const
|
||||||
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 transaction{ dbSession.createSharedTransaction() };
|
||||||
|
|
||||||
auto artist{ Artist::find(dbSession, artistId) };
|
auto artist{ Artist::find(dbSession, artistId) };
|
||||||
|
|||||||
Reference in New Issue
Block a user