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

Media: Join search results with the associated main file

So we can use File.is_present and to simplify integration of Sorting
for search results
parent aa1fc950
......@@ -709,14 +709,16 @@ bool Media::removeLabel( LabelPtr label )
}
}
std::vector<MediaPtr> Media::search( MediaLibraryPtr ml, const std::string& title )
{
static const std::string req = "SELECT * FROM " + policy::MediaTable::Name + " WHERE"
" id_media IN (SELECT rowid FROM " + policy::MediaTable::Name + "Fts"
static const std::string req = "SELECT m.* FROM " + policy::MediaTable::Name + " m "
" INNER JOIN " + policy::FileTable::Name + " f ON m.id_media = f.media_id"
" WHERE"
" m.id_media IN (SELECT rowid FROM " + policy::MediaTable::Name + "Fts"
" WHERE " + policy::MediaTable::Name + "Fts MATCH '*' || ? || '*')"
"AND is_present = 1";
return Media::fetchAll<IMedia>( ml, req, title );
" AND f.is_present = 1"
" AND f.type = ?";
return Media::fetchAll<IMedia>( ml, req, title, File::Type::Main );
}
std::vector<MediaPtr> Media::fetchHistory( MediaLibraryPtr ml )
......
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