Added a way to filter by record label, display labels in the release info panel
This commit is contained in:
@@ -50,7 +50,8 @@ namespace lms::db
|
||||
|| params.track.isValid()
|
||||
|| params.release.isValid()
|
||||
|| params.clusters.size() == 1
|
||||
|| params.mediaLibrary.isValid())
|
||||
|| params.mediaLibrary.isValid()
|
||||
|| params.label.isValid())
|
||||
{
|
||||
query.join("track_artist_link t_a_l ON t_a_l.artist_id = a.id");
|
||||
}
|
||||
@@ -59,7 +60,8 @@ namespace lms::db
|
||||
|| params.sortMethod == ArtistSortMethod::AddedDesc
|
||||
|| params.writtenAfter.isValid()
|
||||
|| params.release.isValid()
|
||||
|| params.mediaLibrary.isValid())
|
||||
|| params.mediaLibrary.isValid()
|
||||
|| params.label.isValid())
|
||||
{
|
||||
query.join("track t ON t.id = t_a_l.track_id");
|
||||
|
||||
@@ -71,6 +73,12 @@ namespace lms::db
|
||||
|
||||
if (params.mediaLibrary.isValid())
|
||||
query.where("t.media_library_id = ?").bind(params.mediaLibrary);
|
||||
|
||||
if (params.label.isValid())
|
||||
{
|
||||
query.join("release_label r_l ON r_l.release_id = t.release_id");
|
||||
query.where("r_l.label_id = ?").bind(params.label);
|
||||
}
|
||||
}
|
||||
|
||||
if (params.linkType)
|
||||
|
||||
@@ -42,10 +42,18 @@ namespace lms::db
|
||||
|
||||
assert(!params.artist.isValid()); // poor check
|
||||
|
||||
if (params.library.isValid())
|
||||
if (params.library.isValid() || params.label.isValid())
|
||||
{
|
||||
query.join("track t ON t.id = t_a_l.track_id");
|
||||
}
|
||||
|
||||
if (params.library.isValid())
|
||||
query.where("t.media_library_id = ?").bind(params.library);
|
||||
|
||||
if (params.label.isValid())
|
||||
{
|
||||
query.join("release_label r_l ON t.release_id = r_l.release_id");
|
||||
query.where("r_l.label_id = ?").bind(params.label);
|
||||
}
|
||||
|
||||
if (params.linkType)
|
||||
@@ -113,6 +121,12 @@ namespace lms::db
|
||||
if (params.library.isValid())
|
||||
query.where("t.media_library_id = ?").bind(params.library);
|
||||
|
||||
if (params.label.isValid())
|
||||
{
|
||||
query.join("release_label r_l ON r_l.release_id = r.id");
|
||||
query.where("r_l.label_id = ?").bind(params.label);
|
||||
}
|
||||
|
||||
if (!params.clusters.empty())
|
||||
{
|
||||
std::ostringstream oss;
|
||||
@@ -160,6 +174,12 @@ namespace lms::db
|
||||
if (params.library.isValid())
|
||||
query.where("t.media_library_id = ?").bind(params.library);
|
||||
|
||||
if (params.label.isValid())
|
||||
{
|
||||
query.join("release_label r_l ON r_l.release_id = t.release_id");
|
||||
query.where("r_l.label_id = ?").bind(params.label);
|
||||
}
|
||||
|
||||
if (!params.clusters.empty())
|
||||
{
|
||||
std::ostringstream oss;
|
||||
|
||||
@@ -1074,6 +1074,9 @@ FROM tracklist)");
|
||||
|
||||
void migrateFromV81(Session& session)
|
||||
{
|
||||
// Make sure we remove all the previoulsy created index, the createIndexesIfNeeded will recreate them all
|
||||
dropIndexes(session);
|
||||
|
||||
// Add country + release country
|
||||
utils::executeCommand(*session.getDboSession(), R"(CREATE TABLE IF NOT EXISTS "country" (
|
||||
"id" integer primary key autoincrement,
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "database/Image.hpp"
|
||||
#include "database/Session.hpp"
|
||||
#include "database/Track.hpp"
|
||||
#include "database/Types.hpp"
|
||||
#include "database/User.hpp"
|
||||
|
||||
#include "EnumSetTraits.hpp"
|
||||
@@ -76,6 +77,12 @@ namespace lms::db
|
||||
if (params.mediaLibrary.isValid())
|
||||
query.where("t.media_library_id = ?").bind(params.mediaLibrary);
|
||||
|
||||
if (params.label.isValid())
|
||||
{
|
||||
query.join("release_label r_l ON r_l.release_id = r.id");
|
||||
query.where("r_l.label_id = ?").bind(params.label);
|
||||
}
|
||||
|
||||
if (params.directory.isValid())
|
||||
query.where("t.directory_id = ?").bind(params.directory);
|
||||
|
||||
@@ -332,6 +339,24 @@ namespace lms::db
|
||||
return utils::fetchQuerySingleResult(session.getDboSession()->query<Wt::Dbo::ptr<Label>>("SELECT l from label l").where("l.name = ?").bind(name));
|
||||
}
|
||||
|
||||
void Label::find(Session& session, LabelSortMethod sortMethod, std::function<void(const Label::pointer& label)> func)
|
||||
{
|
||||
session.checkReadTransaction();
|
||||
|
||||
auto query{ session.getDboSession()->find<Label>() };
|
||||
switch (sortMethod)
|
||||
{
|
||||
case LabelSortMethod::None:
|
||||
break;
|
||||
case LabelSortMethod::Name:
|
||||
query.orderBy("name COLLATE NOCASE");
|
||||
}
|
||||
|
||||
utils::forEachQueryResult(query, [&](const Label::pointer& label) {
|
||||
func(label);
|
||||
});
|
||||
}
|
||||
|
||||
RangeResults<LabelId> Label::findOrphanIds(Session& session, std::optional<Range> range)
|
||||
{
|
||||
session.checkReadTransaction();
|
||||
|
||||
@@ -201,7 +201,7 @@ namespace lms::db
|
||||
utils::executeCommand(_session, "CREATE INDEX IF NOT EXISTS cluster_type_name_idx ON cluster_type(name)");
|
||||
|
||||
utils::executeCommand(_session, "CREATE INDEX IF NOT EXISTS country_id_idx ON country(id)");
|
||||
utils::executeCommand(_session, "CREATE INDEX IF NOT EXISTS country_name_idx ON country(name)");
|
||||
utils::executeCommand(_session, "CREATE INDEX IF NOT EXISTS country_name_idx ON country(name COLLATE NOCASE)");
|
||||
|
||||
utils::executeCommand(_session, "CREATE INDEX IF NOT EXISTS directory_id_idx ON directory(id)");
|
||||
utils::executeCommand(_session, "CREATE INDEX IF NOT EXISTS directory_parent_directory_idx ON directory(parent_directory_id)");
|
||||
@@ -215,7 +215,7 @@ namespace lms::db
|
||||
utils::executeCommand(_session, "CREATE INDEX IF NOT EXISTS image_stem_idx ON image(stem COLLATE NOCASE)");
|
||||
|
||||
utils::executeCommand(_session, "CREATE INDEX IF NOT EXISTS label_id_idx ON label(id)");
|
||||
utils::executeCommand(_session, "CREATE INDEX IF NOT EXISTS label_name_idx ON label(name)");
|
||||
utils::executeCommand(_session, "CREATE INDEX IF NOT EXISTS label_name_idx ON label(name COLLATE NOCASE)");
|
||||
|
||||
utils::executeCommand(_session, "CREATE INDEX IF NOT EXISTS listen_backend_idx ON listen(backend)");
|
||||
utils::executeCommand(_session, "CREATE INDEX IF NOT EXISTS listen_id_idx ON listen(id)");
|
||||
|
||||
@@ -162,6 +162,12 @@ namespace lms::db
|
||||
if (params.mediaLibrary.isValid())
|
||||
query.where("t.media_library_id = ?").bind(params.mediaLibrary);
|
||||
|
||||
if (params.label.isValid())
|
||||
{
|
||||
query.join("release_label r_l ON r_l.release_id = t.release_id");
|
||||
query.where("r_l.label_id = ?").bind(params.label);
|
||||
}
|
||||
|
||||
if (params.directory.isValid())
|
||||
query.where("t.directory_id = ?").bind(params.directory);
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "core/UUID.hpp"
|
||||
#include "database/ArtistId.hpp"
|
||||
#include "database/ClusterId.hpp"
|
||||
#include "database/LabelId.hpp"
|
||||
#include "database/MediaLibraryId.hpp"
|
||||
#include "database/Object.hpp"
|
||||
#include "database/ReleaseId.hpp"
|
||||
@@ -68,6 +69,7 @@ namespace lms::db
|
||||
TrackId track; // artists involved in this track
|
||||
ReleaseId release; // artists involved in this release
|
||||
MediaLibraryId mediaLibrary; // artists that belong to this library
|
||||
LabelId label; // artists that have issued releases using this label
|
||||
|
||||
FindParameters& setClusters(std::span<const ClusterId> _clusters)
|
||||
{
|
||||
@@ -120,6 +122,11 @@ namespace lms::db
|
||||
mediaLibrary = _mediaLibrary;
|
||||
return *this;
|
||||
}
|
||||
FindParameters& setLabel(LabelId _label)
|
||||
{
|
||||
label = _label;
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
Artist() = default;
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
|
||||
#include "database/ArtistId.hpp"
|
||||
#include "database/ClusterId.hpp"
|
||||
#include "database/LabelId.hpp"
|
||||
#include "database/ListenId.hpp"
|
||||
#include "database/MediaLibraryId.hpp"
|
||||
#include "database/Object.hpp"
|
||||
@@ -90,6 +91,7 @@ namespace lms::db
|
||||
std::optional<Range> range;
|
||||
ArtistId artist; // if set, matching this artist
|
||||
MediaLibraryId library;
|
||||
LabelId label;
|
||||
|
||||
StatsFindParameters& setUser(UserId _user)
|
||||
{
|
||||
@@ -126,6 +128,11 @@ namespace lms::db
|
||||
library = _library;
|
||||
return *this;
|
||||
}
|
||||
StatsFindParameters& setLabel(LabelId _label)
|
||||
{
|
||||
label = _label;
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
struct ArtistStatsFindParameters : public StatsFindParameters
|
||||
|
||||
@@ -93,6 +93,7 @@ namespace lms::db
|
||||
static std::size_t getCount(Session& session);
|
||||
static pointer find(Session& session, LabelId id);
|
||||
static pointer find(Session& session, std::string_view name);
|
||||
static void find(Session& session, LabelSortMethod sortMethod, std::function<void(const Label::pointer& label)> func);
|
||||
static RangeResults<LabelId> findOrphanIds(Session& session, std::optional<Range> range = std::nullopt);
|
||||
|
||||
// Accessors
|
||||
@@ -166,6 +167,7 @@ namespace lms::db
|
||||
core::EnumSet<TrackArtistLinkType> excludedTrackArtistLinkTypes; // but not for these link types
|
||||
std::string releaseType; // If set, albums that has this release type
|
||||
MediaLibraryId mediaLibrary; // If set, releases that has at least a track in this library
|
||||
LabelId label; // If set, releases that has this label
|
||||
DirectoryId directory; // if set, releases in this directory (cannot be set with parent directory)
|
||||
DirectoryId parentDirectory; // if set, releases in this parent directory (cannot be set with directory)
|
||||
|
||||
@@ -227,6 +229,11 @@ namespace lms::db
|
||||
mediaLibrary = _mediaLibrary;
|
||||
return *this;
|
||||
}
|
||||
FindParameters& setLabel(LabelId _label)
|
||||
{
|
||||
label = _label;
|
||||
return *this;
|
||||
}
|
||||
FindParameters& setDirectory(DirectoryId _directory)
|
||||
{
|
||||
directory = _directory;
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#include "database/ArtistId.hpp"
|
||||
#include "database/ClusterId.hpp"
|
||||
#include "database/DirectoryId.hpp"
|
||||
#include "database/LabelId.hpp"
|
||||
#include "database/MediaLibraryId.hpp"
|
||||
#include "database/Object.hpp"
|
||||
#include "database/ReleaseId.hpp"
|
||||
@@ -85,6 +86,7 @@ namespace lms::db
|
||||
std::optional<int> trackNumber; // matching this track number
|
||||
std::optional<int> discNumber; // matching this disc number
|
||||
MediaLibraryId mediaLibrary; // If set, tracks in this library
|
||||
LabelId label; // If set, tracks that belongs to a release with this label
|
||||
DirectoryId directory; // if set, tracks in this directory
|
||||
std::optional<bool> hasEmbeddedImage; // if set, tracks that have or not embedded images
|
||||
|
||||
@@ -182,6 +184,11 @@ namespace lms::db
|
||||
mediaLibrary = _mediaLibrary;
|
||||
return *this;
|
||||
}
|
||||
FindParameters& setLabel(LabelId _label)
|
||||
{
|
||||
label = _label;
|
||||
return *this;
|
||||
}
|
||||
FindParameters& setDirectory(DirectoryId _directory)
|
||||
{
|
||||
directory = _directory;
|
||||
|
||||
@@ -136,6 +136,12 @@ namespace lms::db
|
||||
Name,
|
||||
};
|
||||
|
||||
enum class LabelSortMethod
|
||||
{
|
||||
None,
|
||||
Name,
|
||||
};
|
||||
|
||||
enum class ReleaseSortMethod
|
||||
{
|
||||
None,
|
||||
|
||||
@@ -104,6 +104,7 @@ namespace lms::feedback
|
||||
searchParams.setSortMethod(params.sortMethod);
|
||||
searchParams.setRange(params.range);
|
||||
searchParams.setMediaLibrary(params.library);
|
||||
searchParams.setLabel(params.label);
|
||||
|
||||
Session& session{ _db.getTLSSession() };
|
||||
auto transaction{ session.createReadTransaction() };
|
||||
@@ -154,6 +155,7 @@ namespace lms::feedback
|
||||
searchParams.setSortMethod(ReleaseSortMethod::StarredDateDesc);
|
||||
searchParams.setRange(params.range);
|
||||
searchParams.setMediaLibrary(params.library);
|
||||
searchParams.setLabel(params.label);
|
||||
|
||||
Session& session{ _db.getTLSSession() };
|
||||
auto transaction{ session.createReadTransaction() };
|
||||
@@ -204,6 +206,7 @@ namespace lms::feedback
|
||||
searchParams.setSortMethod(TrackSortMethod::StarredDateDesc);
|
||||
searchParams.setRange(params.range);
|
||||
searchParams.setMediaLibrary(params.library);
|
||||
searchParams.setLabel(params.label);
|
||||
|
||||
Session& session{ _db.getTLSSession() };
|
||||
auto transaction{ session.createReadTransaction() };
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
|
||||
#include "database/ArtistId.hpp"
|
||||
#include "database/ClusterId.hpp"
|
||||
#include "database/LabelId.hpp"
|
||||
#include "database/MediaLibraryId.hpp"
|
||||
#include "database/ReleaseId.hpp"
|
||||
#include "database/TrackId.hpp"
|
||||
@@ -57,6 +58,7 @@ namespace lms::feedback
|
||||
std::vector<std::string_view> keywords; // if non empty, name must match all of these keywords
|
||||
std::optional<db::Range> range;
|
||||
db::MediaLibraryId library;
|
||||
db::LabelId label;
|
||||
|
||||
FindParameters& setUser(const db::UserId _user)
|
||||
{
|
||||
@@ -83,6 +85,11 @@ namespace lms::feedback
|
||||
library = _library;
|
||||
return *this;
|
||||
}
|
||||
FindParameters& setLabel(db::LabelId _label)
|
||||
{
|
||||
label = _label;
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
// Artists
|
||||
|
||||
@@ -45,6 +45,7 @@ namespace lms::scrobbling
|
||||
listenFindParams.setKeywords(params.keywords);
|
||||
listenFindParams.setRange(params.range);
|
||||
listenFindParams.setMediaLibrary(params.library);
|
||||
listenFindParams.setLabel(params.label);
|
||||
listenFindParams.setArtist(params.artist);
|
||||
|
||||
return listenFindParams;
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
#include "database/ArtistId.hpp"
|
||||
#include "database/ClusterId.hpp"
|
||||
#include "database/LabelId.hpp"
|
||||
#include "database/MediaLibraryId.hpp"
|
||||
#include "database/ReleaseId.hpp"
|
||||
#include "database/TrackId.hpp"
|
||||
@@ -65,6 +66,7 @@ namespace lms::scrobbling
|
||||
std::vector<std::string_view> keywords; // if non empty, name must match all of these keywords
|
||||
std::optional<db::Range> range;
|
||||
db::MediaLibraryId library; // if set, match this library
|
||||
db::LabelId label; // if set, match this label
|
||||
db::ArtistId artist; // if set, match this artist
|
||||
|
||||
FindParameters& setUser(const db::UserId _user)
|
||||
@@ -92,6 +94,11 @@ namespace lms::scrobbling
|
||||
library = _library;
|
||||
return *this;
|
||||
}
|
||||
FindParameters& setLabel(db::LabelId _label)
|
||||
{
|
||||
label = _label;
|
||||
return *this;
|
||||
}
|
||||
FindParameters& setArtist(db::ArtistId _artist)
|
||||
{
|
||||
artist = _artist;
|
||||
|
||||
Reference in New Issue
Block a user