Commit 6316af64 authored by Matthieu Gallien's avatar Matthieu Gallien 🎵
Browse files

allow to retrieve artist id by name and artist data by id

parent 686df56c
......@@ -639,6 +639,48 @@ DataTypes::ListArtistDataType DatabaseInterface::allArtistsDataByGenre(const QSt
return result;
}
DataTypes::ArtistDataType DatabaseInterface::artistDataFromDatabaseId(qulonglong id)
{
auto result = DataTypes::ArtistDataType{};
if (!d) {
return result;
}
auto transactionResult = startTransaction();
if (!transactionResult) {
return result;
}
result = internalOneArtistPartialData(id);
transactionResult = finishTransaction();
if (!transactionResult) {
return result;
}
return result;
}
qulonglong DatabaseInterface::artistIdFromName(const QString &name)
{
auto result = qulonglong{0};
auto transactionResult = startTransaction();
if (!transactionResult) {
return result;
}
result = internalArtistIdFromName(name);
transactionResult = finishTransaction();
if (!transactionResult) {
return result;
}
return result;
}
DataTypes::ListGenreDataType DatabaseInterface::allGenresData()
{
auto result = DataTypes::ListGenreDataType{};
......@@ -8011,6 +8053,30 @@ DataTypes::AlbumDataType DatabaseInterface::internalOneAlbumPartialData(qulonglo
return result;
}
DataTypes::ArtistDataType DatabaseInterface::internalOneArtistPartialData(qulonglong databaseId)
{
auto result = DataTypes::ArtistDataType{};
d->mSelectArtistQuery.bindValue(QStringLiteral(":artistId"), databaseId);
if (!internalGenericPartialData(d->mSelectArtistQuery)) {
return result;
}
if (d->mSelectArtistQuery.next()) {
const auto &currentRecord = d->mSelectArtistQuery.record();
result[DataTypes::DatabaseIdRole] = currentRecord.value(0);
result[DataTypes::TitleRole] = currentRecord.value(1);
result[DataTypes::GenreRole] = QVariant::fromValue(currentRecord.value(2).toString().split(QStringLiteral(", ")));
result[DataTypes::ElementTypeRole] = ElisaUtils::Artist;
}
d->mSelectArtistQuery.finish();
return result;
}
DataTypes::ListTrackDataType DatabaseInterface::internalAllTracksPartialData()
{
auto result = DataTypes::ListTrackDataType{};
......
......@@ -72,6 +72,10 @@ public:
DataTypes::ListArtistDataType allArtistsDataByGenre(const QString &genre);
DataTypes::ArtistDataType artistDataFromDatabaseId(qulonglong id);
qulonglong artistIdFromName(const QString &name);
DataTypes::ListGenreDataType allGenresData();
bool internalArtistMatchGenre(qulonglong databaseId, const QString &genre);
......@@ -255,6 +259,8 @@ private:
DataTypes::AlbumDataType internalOneAlbumPartialData(qulonglong databaseId);
DataTypes::ArtistDataType internalOneArtistPartialData(qulonglong databaseId);
DataTypes::ListTrackDataType internalAllTracksPartialData();
DataTypes::ListRadioDataType internalAllRadiosPartialData();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment