2022-09-12 01:33:38 +00:00
|
|
|
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace OCA\Memories\Db;
|
|
|
|
|
|
|
|
use OCP\DB\QueryBuilder\IQueryBuilder;
|
2022-09-12 03:03:04 +00:00
|
|
|
use OCP\ITags;
|
2022-09-12 01:33:38 +00:00
|
|
|
|
|
|
|
trait TimelineQueryFavorites {
|
2022-09-12 03:03:04 +00:00
|
|
|
public function transformFavoriteFilter(IQueryBuilder $query, string $userId) {
|
|
|
|
// Inner join will filter only the favorites
|
|
|
|
$query->innerJoin('m', 'vcategory_to_object', 'vco', $query->expr()->eq('vco.objid', 'm.fileid'));
|
|
|
|
|
|
|
|
// Get the favorites category only
|
|
|
|
$query->innerJoin('vco', 'vcategory', 'vc', $query->expr()->andX(
|
|
|
|
$query->expr()->eq('vc.id', 'vco.categoryid'),
|
|
|
|
$query->expr()->eq('vc.uid', $query->createNamedParameter($userId)),
|
|
|
|
$query->expr()->eq('vc.category', $query->createNamedParameter(ITags::TAG_FAVORITE)),
|
|
|
|
));
|
2022-09-12 01:33:38 +00:00
|
|
|
}
|
|
|
|
}
|