Use DISTINCT for selection

pull/62/head
Varun Patil 2022-09-14 15:36:06 -07:00
parent 1f847bf488
commit 111e408ebd
1 changed files with 2 additions and 6 deletions

View File

@ -39,7 +39,8 @@ trait TimelineQueryDay {
$whereFilecache
) {
// Get all entries also present in filecache
$query->select('m.fileid', 'f.etag', 'm.isvideo', 'vco.categoryid')
$fileid = $query->createFunction('DISTINCT m.fileid');
$query->select($fileid, 'f.etag', 'm.isvideo', 'vco.categoryid')
->from('memories', 'm')
->innerJoin('m', 'filecache', 'f',
$query->expr()->andX(
@ -51,11 +52,6 @@ trait TimelineQueryDay {
// Add favorite field
$this->addFavoriteTag($query, $user);
// Get distinct fileids only
// This is required when browsing a folder in external storage
// since the same file can be present for multiple users
$query->groupBy('m.fileid');
// Group and sort by date taken
$query->orderBy('m.datetaken', 'DESC');
return $query;