Fallback on the cluster similarity searcher if no song is classified
This commit is contained in:
@@ -45,7 +45,9 @@ Searcher::getSimilarTracks(Wt::Dbo::Session& session, const std::set<Database::I
|
|||||||
auto somSearcher = _somAddon.getSearcher();
|
auto somSearcher = _somAddon.getSearcher();
|
||||||
|
|
||||||
if (method == Database::SimilaritySettings::PreferredMethod::Features
|
if (method == Database::SimilaritySettings::PreferredMethod::Features
|
||||||
|| (method == Database::SimilaritySettings::PreferredMethod::Auto && somSearcher))
|
|| (method == Database::SimilaritySettings::PreferredMethod::Auto
|
||||||
|
&& somSearcher
|
||||||
|
&& std::any_of(std::cbegin(trackIds), std::cend(trackIds), [&](Database::IdType trackId) { return somSearcher->isTrackClassified(trackId); } )))
|
||||||
{
|
{
|
||||||
return somSearcher->getSimilarTracks(trackIds, maxCount);
|
return somSearcher->getSimilarTracks(trackIds, maxCount);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -221,6 +221,12 @@ FeaturesSearcher::isValid() const
|
|||||||
return _network.get() != nullptr;
|
return _network.get() != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
FeaturesSearcher::isTrackClassified(Database::IdType trackId) const
|
||||||
|
{
|
||||||
|
return (_trackPositions.find(trackId) != _trackPositions.end());
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
FeaturesSearcher::isReleaseClassified(Database::IdType releaseId) const
|
FeaturesSearcher::isReleaseClassified(Database::IdType releaseId) const
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -43,8 +43,9 @@ class FeaturesSearcher
|
|||||||
|
|
||||||
bool isValid() const;
|
bool isValid() const;
|
||||||
|
|
||||||
|
bool isTrackClassified(Database::IdType trackId) const;
|
||||||
bool isReleaseClassified(Database::IdType releaseId) const;
|
bool isReleaseClassified(Database::IdType releaseId) const;
|
||||||
bool isArtistClassified(Database::IdType releaseId) const;
|
bool isArtistClassified(Database::IdType artistId) const;
|
||||||
|
|
||||||
std::vector<Database::IdType> getSimilarTracks(const std::set<Database::IdType>& tracksId, std::size_t maxCount) const;
|
std::vector<Database::IdType> getSimilarTracks(const std::set<Database::IdType>& tracksId, std::size_t maxCount) const;
|
||||||
std::vector<Database::IdType> getSimilarReleases(Database::IdType releaseId, std::size_t maxCount) const;
|
std::vector<Database::IdType> getSimilarReleases(Database::IdType releaseId, std::size_t maxCount) const;
|
||||||
|
|||||||
Reference in New Issue
Block a user