mirror of
https://github.com/wallabag/wallabag.git
synced 2025-10-20 19:52:09 +00:00
Allow to remove all archived entries
Since we still support fucking SQLite, we need to retrieve all tags & annotations for archived entries before deleting them. Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
fa884b30ba
commit
6da1aebc94
18 changed files with 205 additions and 1 deletions
|
@ -371,4 +371,12 @@ class EntryRepository extends EntityRepository
|
|||
->setParameter('userId', $userId)
|
||||
->execute();
|
||||
}
|
||||
|
||||
public function removeArchivedByUserId($userId)
|
||||
{
|
||||
$this->getEntityManager()
|
||||
->createQuery('DELETE FROM Wallabag\CoreBundle\Entity\Entry e WHERE e.user = :userId AND e.isArchived = TRUE')
|
||||
->setParameter('userId', $userId)
|
||||
->execute();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,4 +76,24 @@ class TagRepository extends EntityRepository
|
|||
->getQuery()
|
||||
->getSingleResult();
|
||||
}
|
||||
|
||||
public function findTagsForArchivedArticles($userId)
|
||||
{
|
||||
$ids = $this->createQueryBuilder('t')
|
||||
->select('t.id')
|
||||
->leftJoin('t.entries', 'e')
|
||||
->where('e.user = :userId')->setParameter('userId', $userId)
|
||||
->andWhere('e.isArchived = true')
|
||||
->groupBy('t.id')
|
||||
->orderBy('t.slug')
|
||||
->getQuery()
|
||||
->getArrayResult();
|
||||
|
||||
$tags = [];
|
||||
foreach ($ids as $id) {
|
||||
$tags[] = $this->find($id);
|
||||
}
|
||||
|
||||
return $tags;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue