}
/**
- * Retrieves untagged entries for a user.
+ * Retrieve a sorted list of untagged entries for a user.
*
* @param int $userId
*
public function getBuilderForUntaggedByUser($userId)
{
return $this
- ->getSortedQueryBuilderByUser($userId)
- ->andWhere('size(e.tags) = 0');
+ ->sortQueryBuilder($this->getRawBuilderForUntaggedByUser($userId));
+ }
+
+ /**
+ * Retrieve untagged entries for a user.
+ *
+ * @param int $userId
+ *
+ * @return QueryBuilder
+ */
+ public function getRawBuilderForUntaggedByUser($userId)
+ {
+ return $this->getQueryBuilderByUser($userId)
+ ->leftJoin('e.tags', 't')
+ ->andWhere('t.id is null');
}
/**
$qb->orderBy('e.id', $order);
} elseif ('updated' === $sort) {
$qb->orderBy('e.updatedAt', $order);
+ } else if ('archived' === $sort) {
+ $qb->orderBy('e.archivedAt', $order);
}
$pagerAdapter = new DoctrineORMAdapter($qb, true, false);
/**
* Return a query builder to be used by other getBuilderFor* method.
*
- * @param int $userId
+ * @param int $userId
*
* @return QueryBuilder
*/
*/
private function getSortedQueryBuilderByUser($userId, $sortBy = 'createdAt', $direction = 'desc')
{
- return $this->sortQueryBuilder($this->getQueryBuilderByUser($userId));
+ return $this->sortQueryBuilder($this->getQueryBuilderByUser($userId), $sortBy, $direction);
}
/**
- * Return the given QueryBuilder with an orderBy() call
- *
+ * Return the given QueryBuilder with an orderBy() call.
+ *
* @param QueryBuilder $qb
- * @param string $sortBy
- * @param string $direction
+ * @param string $sortBy
+ * @param string $direction
*
* @return QueryBuilder
*/