Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
VideoLAN
medialibrary
Commits
a5c453a5
Commit
a5c453a5
authored
Jun 26, 2018
by
Hugo Beauzée-Luyssen
Browse files
IAlbum: Pass a QueryParameters to list artists
Mostly for consistency with the other methods
parent
95752202
Changes
5
Hide whitespace changes
Inline
Side-by-side
include/medialibrary/IAlbum.h
View file @
a5c453a5
...
...
@@ -61,7 +61,7 @@ public:
* Artists are sorted by name.
* @param desc
*/
virtual
Query
<
IArtist
>
artists
(
bool
desc
)
const
=
0
;
virtual
Query
<
IArtist
>
artists
(
const
QueryParameters
*
params
=
nullptr
)
const
=
0
;
/**
* @brief nbTracks Returns the amount of track in this album.
* The value is cached, and doesn't require fetching anything.
...
...
src/Album.cpp
View file @
a5c453a5
...
...
@@ -354,12 +354,12 @@ bool Album::setAlbumArtist( std::shared_ptr<Artist> artist )
return
true
;
}
Query
<
IArtist
>
Album
::
artists
(
bool
desc
)
const
Query
<
IArtist
>
Album
::
artists
(
const
QueryParameters
*
params
)
const
{
std
::
string
req
=
"FROM "
+
policy
::
ArtistTable
::
Name
+
" art "
"INNER JOIN AlbumArtistRelation aar ON aar.artist_id = art.id_artist "
"WHERE aar.album_id = ? ORDER BY art.name"
;
if
(
desc
==
true
)
if
(
params
!=
nullptr
&&
params
->
desc
==
true
)
req
+=
" DESC"
;
return
make_query
<
Artist
,
IArtist
>
(
m_ml
,
"art.*"
,
std
::
move
(
req
),
m_id
);
}
...
...
src/Album.h
View file @
a5c453a5
...
...
@@ -96,7 +96,7 @@ class Album : public IAlbum, public DatabaseHelpers<Album, policy::AlbumTable>
virtual
ArtistPtr
albumArtist
()
const
override
;
bool
setAlbumArtist
(
std
::
shared_ptr
<
Artist
>
artist
);
virtual
Query
<
IArtist
>
artists
(
bool
desc
)
const
override
;
virtual
Query
<
IArtist
>
artists
(
const
QueryParameters
*
params
)
const
override
;
bool
addArtist
(
std
::
shared_ptr
<
Artist
>
artist
);
bool
removeArtist
(
Artist
*
artist
);
...
...
test/samples/Tester.cpp
View file @
a5c453a5
...
...
@@ -387,7 +387,7 @@ void Tests::checkAlbums( const rapidjson::Value& expectedAlbums, std::vector<Alb
if
(
expectedAlbum
.
HasMember
(
"artists"
)
)
{
const
auto
&
expectedArtists
=
expectedAlbum
[
"artists"
];
auto
artists
=
a
->
artists
(
false
)
->
all
();
auto
artists
=
a
->
artists
(
nullptr
)
->
all
();
if
(
expectedArtists
.
Size
()
!=
artists
.
size
()
)
return
false
;
for
(
auto
i
=
0u
;
i
<
expectedArtists
.
Size
();
++
i
)
...
...
test/unittest/AlbumTests.cpp
View file @
a5c453a5
...
...
@@ -232,13 +232,13 @@ TEST_F( Albums, Artists )
res
=
album
->
addArtist
(
artist2
);
ASSERT_EQ
(
res
,
true
);
auto
artists
=
album
->
artists
(
false
)
->
all
();
auto
artists
=
album
->
artists
(
nullptr
)
->
all
();
ASSERT_EQ
(
artists
.
size
(),
2u
);
Reload
();
album
=
std
::
static_pointer_cast
<
Album
>
(
ml
->
album
(
album
->
id
()
)
);
artists
=
album
->
artists
(
false
)
->
all
();
artists
=
album
->
artists
(
nullptr
)
->
all
();
ASSERT_EQ
(
album
->
albumArtist
(),
nullptr
);
ASSERT_EQ
(
artists
.
size
(),
2u
);
}
...
...
@@ -252,12 +252,14 @@ TEST_F( Albums, SortArtists )
album
->
addArtist
(
artist1
);
album
->
addArtist
(
artist2
);
auto
artists
=
album
->
artists
(
false
)
->
all
();
QueryParameters
params
{
SortingCriteria
::
Default
,
false
};
auto
artists
=
album
->
artists
(
&
params
)
->
all
();
ASSERT_EQ
(
artists
.
size
(),
2u
);
ASSERT_EQ
(
artist1
->
id
(),
artists
[
1
]
->
id
()
);
ASSERT_EQ
(
artist2
->
id
(),
artists
[
0
]
->
id
()
);
artists
=
album
->
artists
(
true
)
->
all
();
params
.
desc
=
true
;
artists
=
album
->
artists
(
&
params
)
->
all
();
ASSERT_EQ
(
artists
.
size
(),
2u
);
ASSERT_EQ
(
artist1
->
id
(),
artists
[
0
]
->
id
()
);
ASSERT_EQ
(
artist2
->
id
(),
artists
[
1
]
->
id
()
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment