Added barcode tag parsing in releases, and take it into account to avoid merging unrelated albums, fixes #550

This commit is contained in:
emeric
2024-11-14 13:22:05 +01:00
parent 0164038794
commit 5504ee707c
7 changed files with 26 additions and 2 deletions
+11 -1
View File
@@ -35,7 +35,7 @@ namespace lms::db
{
namespace
{
static constexpr Version LMS_DATABASE_VERSION{ 72 };
static constexpr Version LMS_DATABASE_VERSION{ 73 };
}
VersionInfo::VersionInfo()
@@ -932,6 +932,15 @@ SELECT
utils::executeCommand(*session.getDboSession(), R"(CREATE INDEX "playqueue_track_track" on "playqueue_track" ("track_id"))");
}
void migrateFromV72(Session& session)
{
// Add catalog number
utils::executeCommand(*session.getDboSession(), "ALTER TABLE release ADD barcode TEXT NOT NULL DEFAULT ''");
// Just increment the scan version of the settings to make the next scheduled scan rescan everything
utils::executeCommand(*session.getDboSession(), "UPDATE scan_settings SET scan_version = scan_version + 1");
}
bool doDbMigration(Session& session)
{
constexpr std::string_view outdatedMsg{ "Outdated database, please rebuild it (delete the .db file and restart)" };
@@ -980,6 +989,7 @@ SELECT
{ 69, migrateFromV69 },
{ 70, migrateFromV70 },
{ 71, migrateFromV71 },
{ 72, migrateFromV72 },
};
bool migrationPerformed{};
@@ -252,6 +252,7 @@ namespace lms::db
std::vector<std::string> getLabelNames() const;
std::vector<std::string> getReleaseTypeNames() const;
void visitLabels(const std::function<void(const Label::pointer& label)>& _func) const;
std::string_view getBarcode() const { return _barcode; }
ObjectPtr<Image> getImage() const;
// Setters
@@ -266,6 +267,7 @@ namespace lms::db
void clearReleaseTypes();
void addLabel(ObjectPtr<Label> releaseType);
void addReleaseType(ObjectPtr<ReleaseType> releaseType);
void setBarcode(std::string_view barcode) { _barcode = barcode; }
void setImage(ObjectPtr<Image> image);
// Get the artists of this release
@@ -286,6 +288,7 @@ namespace lms::db
Wt::Dbo::field(a, _totalDisc, "total_disc");
Wt::Dbo::field(a, _artistDisplayName, "artist_display_name");
Wt::Dbo::field(a, _isCompilation, "is_compilation");
Wt::Dbo::field(a, _barcode, "barcode");
Wt::Dbo::hasMany(a, _tracks, Wt::Dbo::ManyToOne, "release");
Wt::Dbo::belongsTo(a, _image, "image", Wt::Dbo::OnDeleteSetNull);
@@ -310,6 +313,7 @@ namespace lms::db
std::optional<int> _totalDisc{};
std::string _artistDisplayName;
bool _isCompilation{}; // See https://picard-docs.musicbrainz.org/en/appendices/tag_mapping.html#compilation-itunes-5
std::string _barcode;
Wt::Dbo::ptr<Image> _image;
Wt::Dbo::collection<Wt::Dbo::ptr<Track>> _tracks;