Added a way to disable the similarity engine
This commit is contained in:
@@ -32,72 +32,74 @@ LMS_DECLARE_IDTYPE(ScanSettingsId)
|
||||
|
||||
namespace Database {
|
||||
|
||||
class ClusterType;
|
||||
class Session;
|
||||
class ClusterType;
|
||||
class Session;
|
||||
|
||||
class ScanSettings final : public Object<ScanSettings, ScanSettingsId>
|
||||
{
|
||||
public:
|
||||
// Do not modify values (just add)
|
||||
enum class UpdatePeriod
|
||||
{
|
||||
Never = 0,
|
||||
Daily,
|
||||
Weekly,
|
||||
Monthly,
|
||||
Hourly,
|
||||
};
|
||||
class ScanSettings final : public Object<ScanSettings, ScanSettingsId>
|
||||
{
|
||||
public:
|
||||
// Do not modify values (just add)
|
||||
enum class UpdatePeriod
|
||||
{
|
||||
Never = 0,
|
||||
Daily,
|
||||
Weekly,
|
||||
Monthly,
|
||||
Hourly,
|
||||
};
|
||||
|
||||
// Do not modify values (just add)
|
||||
enum class RecommendationEngineType
|
||||
{
|
||||
Clusters = 0,
|
||||
Features,
|
||||
};
|
||||
// Do not modify values (just add)
|
||||
enum class SimilarityEngineType
|
||||
{
|
||||
Clusters = 0,
|
||||
Features,
|
||||
None,
|
||||
};
|
||||
|
||||
static void init(Session& session);
|
||||
static void init(Session& session);
|
||||
|
||||
static pointer get(Session& session);
|
||||
static pointer get(Session& session);
|
||||
|
||||
// Getters
|
||||
std::size_t getScanVersion() const { return _scanVersion; }
|
||||
std::filesystem::path getMediaDirectory() const { return _mediaDirectory; }
|
||||
Wt::WTime getUpdateStartTime() const { return _startTime; }
|
||||
UpdatePeriod getUpdatePeriod() const { return _updatePeriod; }
|
||||
std::vector<ObjectPtr<ClusterType>> getClusterTypes() const;
|
||||
std::vector<std::filesystem::path> getAudioFileExtensions() const;
|
||||
RecommendationEngineType getRecommendationEngineType() const { return _recommendationEngineType; }
|
||||
// Getters
|
||||
std::size_t getScanVersion() const { return _scanVersion; }
|
||||
std::filesystem::path getMediaDirectory() const { return _mediaDirectory; }
|
||||
Wt::WTime getUpdateStartTime() const { return _startTime; }
|
||||
UpdatePeriod getUpdatePeriod() const { return _updatePeriod; }
|
||||
std::vector<ObjectPtr<ClusterType>> getClusterTypes() const;
|
||||
std::vector<std::filesystem::path> getAudioFileExtensions() const;
|
||||
SimilarityEngineType getSimilarityEngineType() const { return _similarityEngineType; }
|
||||
|
||||
// Setters
|
||||
void addAudioFileExtension(const std::filesystem::path& ext);
|
||||
void setMediaDirectory(const std::filesystem::path& p);
|
||||
void setUpdateStartTime(Wt::WTime t) { _startTime = t; }
|
||||
void setUpdatePeriod(UpdatePeriod p) { _updatePeriod = p; }
|
||||
void setClusterTypes(Session& session, const std::set<std::string>& clusterTypeNames);
|
||||
void setRecommendationEngineType(RecommendationEngineType type) { _recommendationEngineType = type; }
|
||||
void incScanVersion();
|
||||
// Setters
|
||||
void addAudioFileExtension(const std::filesystem::path& ext);
|
||||
void setMediaDirectory(const std::filesystem::path& p);
|
||||
void setUpdateStartTime(Wt::WTime t) { _startTime = t; }
|
||||
void setUpdatePeriod(UpdatePeriod p) { _updatePeriod = p; }
|
||||
void setClusterTypes(Session& session, const std::set<std::string>& clusterTypeNames);
|
||||
void setSimilarityEngineType(SimilarityEngineType type) { _similarityEngineType = type; }
|
||||
void incScanVersion();
|
||||
|
||||
template<class Action>
|
||||
void persist(Action& a)
|
||||
{
|
||||
Wt::Dbo::field(a, _scanVersion, "scan_version");
|
||||
Wt::Dbo::field(a, _mediaDirectory, "media_directory");
|
||||
Wt::Dbo::field(a, _startTime, "start_time");
|
||||
Wt::Dbo::field(a, _updatePeriod, "update_period");
|
||||
Wt::Dbo::field(a, _audioFileExtensions, "audio_file_extensions");
|
||||
Wt::Dbo::field(a, _recommendationEngineType,"similarity_engine_type");
|
||||
Wt::Dbo::hasMany(a, _clusterTypes, Wt::Dbo::ManyToOne, "scan_settings");
|
||||
}
|
||||
template<class Action>
|
||||
void persist(Action& a)
|
||||
{
|
||||
Wt::Dbo::field(a, _scanVersion, "scan_version");
|
||||
Wt::Dbo::field(a, _mediaDirectory, "media_directory");
|
||||
Wt::Dbo::field(a, _startTime, "start_time");
|
||||
Wt::Dbo::field(a, _updatePeriod, "update_period");
|
||||
Wt::Dbo::field(a, _audioFileExtensions, "audio_file_extensions");
|
||||
Wt::Dbo::field(a, _similarityEngineType, "similarity_engine_type");
|
||||
Wt::Dbo::hasMany(a, _clusterTypes, Wt::Dbo::ManyToOne, "scan_settings");
|
||||
}
|
||||
|
||||
private:
|
||||
int _scanVersion {};
|
||||
std::string _mediaDirectory;
|
||||
Wt::WTime _startTime = Wt::WTime {0,0,0};
|
||||
UpdatePeriod _updatePeriod {UpdatePeriod::Never};
|
||||
RecommendationEngineType _recommendationEngineType {RecommendationEngineType::Clusters};
|
||||
std::string _audioFileExtensions {".alac .mp3 .ogg .oga .aac .m4a .m4b .flac .wav .wma .aif .aiff .ape .mpc .shn .opus .wv"};
|
||||
Wt::Dbo::collection<Wt::Dbo::ptr<ClusterType>> _clusterTypes;
|
||||
};
|
||||
private:
|
||||
int _scanVersion{};
|
||||
std::string _mediaDirectory;
|
||||
Wt::WTime _startTime = Wt::WTime{ 0,0,0 };
|
||||
UpdatePeriod _updatePeriod{ UpdatePeriod::Never };
|
||||
SimilarityEngineType _similarityEngineType{ SimilarityEngineType::Clusters };
|
||||
std::string _audioFileExtensions{ ".alac .mp3 .ogg .oga .aac .m4a .m4b .flac .wav .wma .aif .aiff .ape .mpc .shn .opus .wv" };
|
||||
|
||||
Wt::Dbo::collection<Wt::Dbo::ptr<ClusterType>> _clusterTypes;
|
||||
};
|
||||
|
||||
|
||||
} // namespace Database
|
||||
|
||||
@@ -159,12 +159,12 @@ namespace Recommendation
|
||||
}
|
||||
|
||||
static
|
||||
Database::ScanSettings::RecommendationEngineType
|
||||
getRecommendationEngineType(Database::Session& session)
|
||||
Database::ScanSettings::SimilarityEngineType
|
||||
getSimilarityEngineType(Database::Session& session)
|
||||
{
|
||||
auto transaction {session.createSharedTransaction()};
|
||||
|
||||
return Database::ScanSettings::get(session)->getRecommendationEngineType();
|
||||
return Database::ScanSettings::get(session)->getSimilarityEngineType();
|
||||
}
|
||||
|
||||
void
|
||||
@@ -184,20 +184,24 @@ namespace Recommendation
|
||||
_engines.clear();
|
||||
}
|
||||
|
||||
switch (getRecommendationEngineType(_db.getTLSSession()))
|
||||
switch (getSimilarityEngineType(_db.getTLSSession()))
|
||||
{
|
||||
case ScanSettings::RecommendationEngineType::Clusters:
|
||||
case ScanSettings::SimilarityEngineType::Clusters:
|
||||
_enginePriorities = {EngineType::Clusters};
|
||||
enginesToLoad.try_emplace(EngineType::Clusters, createClustersEngine(_db));
|
||||
break;
|
||||
|
||||
case ScanSettings::RecommendationEngineType::Features:
|
||||
case ScanSettings::SimilarityEngineType::Features:
|
||||
_enginePriorities = {EngineType::Features, EngineType::Clusters};
|
||||
|
||||
// not same order since clusters is faster to load
|
||||
enginesToLoad.try_emplace(EngineType::Clusters, createClustersEngine(_db));
|
||||
enginesToLoad.try_emplace(EngineType::Features, createFeaturesEngine(_db));
|
||||
break;
|
||||
|
||||
case ScanSettings::SimilarityEngineType::None:
|
||||
_enginePriorities.clear();
|
||||
break;
|
||||
}
|
||||
|
||||
assert(_pendingEngines.empty());
|
||||
|
||||
@@ -381,7 +381,7 @@ ScannerService::readSettings()
|
||||
std::transform(std::cbegin(fileExtensions), std::end(fileExtensions), std::back_inserter(newSettings.supportedExtensions),
|
||||
[](const std::filesystem::path& extension) { return std::filesystem::path{ StringUtils::stringToLower(extension.string()) }; });
|
||||
}
|
||||
newSettings.recommendationServiceType = scanSettings->getRecommendationEngineType();
|
||||
newSettings.similarityServiceType = scanSettings->getSimilarityEngineType();
|
||||
newSettings.mediaDirectory = scanSettings->getMediaDirectory();
|
||||
|
||||
const auto clusterTypes = scanSettings->getClusterTypes();
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace Scanner
|
||||
Wt::WTime startTime;
|
||||
Database::ScanSettings::UpdatePeriod updatePeriod {Database::ScanSettings::UpdatePeriod::Never};
|
||||
std::vector<std::filesystem::path> supportedExtensions;
|
||||
Database::ScanSettings::RecommendationEngineType recommendationServiceType;
|
||||
Database::ScanSettings::SimilarityEngineType similarityServiceType;
|
||||
std::filesystem::path mediaDirectory;
|
||||
bool skipDuplicateMBID {};
|
||||
std::set<std::string> clusterTypeNames;
|
||||
@@ -45,7 +45,7 @@ namespace Scanner
|
||||
&& startTime == rhs.startTime
|
||||
&& updatePeriod == rhs.updatePeriod
|
||||
&& supportedExtensions == rhs.supportedExtensions
|
||||
&& recommendationServiceType == rhs.recommendationServiceType
|
||||
&& similarityServiceType == rhs.similarityServiceType
|
||||
&& mediaDirectory == rhs.mediaDirectory
|
||||
&& skipDuplicateMBID == rhs.skipDuplicateMBID
|
||||
&& clusterTypeNames == rhs.clusterTypeNames;
|
||||
|
||||
Reference in New Issue
Block a user