Added album sort name in subsonic responses, fixes #419

This commit is contained in:
emeric
2024-03-02 23:05:20 +01:00
parent f20db00417
commit b45513a611
17 changed files with 56 additions and 18 deletions
+20
View File
@@ -30,6 +30,15 @@
namespace Database
{
namespace
{
static constexpr Version LMS_DATABASE_VERSION{ 53 };
}
VersionInfo::VersionInfo()
: _version{ LMS_DATABASE_VERSION }
{}
VersionInfo::pointer VersionInfo::getOrCreate(Session& session)
{
session.checkWriteTransaction();
@@ -401,6 +410,16 @@ SELECT
session.getDboSession().execute("ALTER TABLE scan_settings ADD default_tag_delimiters TEXT NOT NULL DEFAULT ''");
}
void migrateFromV52(Session& session)
{
// Add sort name for releases
session.getDboSession().execute("ALTER TABLE release ADD sort_name TEXT NOT NULL DEFAULT ''");
// Just increment the scan version of the settings to make the next scheduled scan rescan everything
session.getDboSession().execute("UPDATE scan_settings SET scan_version = scan_version + 1");
}
void doDbMigration(Session& session)
{
static const std::string outdatedMsg{ "Outdated database, please rebuild it (delete the .db file and restart)" };
@@ -430,6 +449,7 @@ SELECT
{49, migrateFromV49},
{50, migrateFromV50},
{51, migrateFromV51},
{52, migrateFromV52},
};
{
+4 -2
View File
@@ -26,12 +26,14 @@ namespace Database
class Session;
using Version = std::size_t;
static constexpr Version LMS_DATABASE_VERSION{ 52 };
class VersionInfo
{
public:
using pointer = Wt::Dbo::ptr<VersionInfo>;
VersionInfo();
static VersionInfo::pointer getOrCreate(Session& session);
static VersionInfo::pointer get(Session& session);
@@ -45,7 +47,7 @@ namespace Database
}
private:
int _version{ LMS_DATABASE_VERSION };
int _version;
};
namespace Migration
@@ -143,7 +143,8 @@ namespace Database
std::size_t getMeanBitrate() const;
// Accessors
const std::string& getName() const { return _name; }
std::string_view getName() const { return _name; }
std::string_view getSortName() const { return _sortName; }
std::optional<UUID> getMBID() const { return UUID::fromString(_MBID); }
std::optional<std::size_t> getTotalDisc() const { return _totalDisc; }
std::size_t getDiscCount() const; // may not be total disc (if incomplete for example)
@@ -157,6 +158,7 @@ namespace Database
// Setters
void setName(std::string_view name) { _name = name; }
void setSortName(std::string_view sortName) { _sortName = sortName; }
void setMBID(const std::optional<UUID>& mbid) { _MBID = mbid ? mbid->getAsString() : ""; }
void setTotalDisc(std::optional<int> totalDisc) { _totalDisc = totalDisc; }
void setArtistDisplayName(std::string_view name) { _artistDisplayName = name; }
@@ -173,6 +175,7 @@ namespace Database
void persist(Action& a)
{
Wt::Dbo::field(a, _name, "name");
Wt::Dbo::field(a, _sortName, "sort_name");
Wt::Dbo::field(a, _MBID, "mbid");
Wt::Dbo::field(a, _totalDisc, "total_disc");
Wt::Dbo::field(a, _artistDisplayName, "artist_display_name");
@@ -191,6 +194,7 @@ namespace Database
static constexpr std::size_t _maxNameLength{ 256 };
std::string _name;
std::string _sortName;
std::string _MBID;
std::optional<int> _totalDisc{};
std::string _artistDisplayName;