Commit 2e914dc0 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

MediaLibrary: Move entry points fetching in the Folder class

And support fetching entrypoints by their parent device
parent 94cd4b2b
......@@ -290,6 +290,16 @@ Query<IFolder> Folder::searchWithMedia( MediaLibraryPtr ml, const std::string& p
return make_query<Folder, IFolder>( ml, "*", req, sortRequest( params ), pattern );
}
Query<IFolder> Folder::entryPoints( MediaLibraryPtr ml, int64_t deviceId )
{
std::string req = "FROM " + Folder::Table::Name + " WHERE parent_id IS NULL"
" AND is_banned = 0";
if ( deviceId == 0 )
return make_query<Folder, IFolder>( ml, "*", req, "" );
req += " AND device_id = ?";
return make_query<Folder, IFolder>( ml, "*", req, "", sqlite::ForeignKey{ deviceId } );
}
int64_t Folder::id() const
{
return m_id;
......
......@@ -67,6 +67,7 @@ public:
static Query<IFolder> withMedia( MediaLibraryPtr ml, const QueryParameters* params );
static Query<IFolder> searchWithMedia( MediaLibraryPtr ml, const std::string& pattern,
const QueryParameters* params );
static Query<IFolder> entryPoints( MediaLibraryPtr ml, int64_t deviceId );
virtual int64_t id() const override;
virtual const std::string& mrl() const override;
......
......@@ -1372,9 +1372,7 @@ bool MediaLibrary::setDiscoverNetworkEnabled( bool enabled )
Query<IFolder> MediaLibrary::entryPoints() const
{
static const std::string req = "FROM " + Folder::Table::Name + " WHERE parent_id IS NULL"
" AND is_banned = 0";
return make_query<Folder, IFolder>( this, "*", req, "" );
return Folder::entryPoints( this, 0 );
}
bool MediaLibrary::isIndexed( const std::string& mrl ) const
......
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