Add attachment indicator

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl
2018-06-12 17:14:54 +02:00
parent ee5a54a575
commit 0137b882c5
7 changed files with 64 additions and 12 deletions

View File

@@ -53,7 +53,7 @@ class AttachmentMapper extends DeckMapper implements IPermissionMapper {
$qb = $this->db->getQueryBuilder();
$qb->select('*')
->from('deck_attachment')
->where($qb->expr()->eq('id', $id));
->where($qb->expr()->eq('id', (string)$id));
$cursor = $qb->execute();
$row = $cursor->fetch(PDO::FETCH_ASSOC);
@@ -71,7 +71,9 @@ class AttachmentMapper extends DeckMapper implements IPermissionMapper {
$qb = $this->db->getQueryBuilder();
$qb->select('*')
->from('deck_attachment')
->where($qb->expr()->eq('card_id', $cardId, IQueryBuilder::PARAM_INT));
->where($qb->expr()->eq('card_id', (string)$cardId, IQueryBuilder::PARAM_INT))
->andWhere($qb->expr()->eq('deleted_at', (string)0, IQueryBuilder::PARAM_INT));
$entities = [];
$cursor = $qb->execute();
@@ -82,14 +84,21 @@ class AttachmentMapper extends DeckMapper implements IPermissionMapper {
return $entities;
}
public function findToDelete() {
public function findToDelete($cardId = null, $withOffset = true) {
// add buffer of 5 min
$timeLimit = time() - (60 * 5);
$qb = $this->db->getQueryBuilder();
$qb->select('*')
->from('deck_attachment')
->where($qb->expr()->gt('deleted_at', '0', IQueryBuilder::PARAM_INT))
->andWhere($qb->expr()->lt('deleted_at', (string)$timeLimit, IQueryBuilder::PARAM_INT));
->where($qb->expr()->gt('deleted_at', '0', IQueryBuilder::PARAM_INT));
if ($withOffset) {
$qb
->andWhere($qb->expr()->lt('deleted_at', (string)$timeLimit, IQueryBuilder::PARAM_INT));
}
if ($cardId !== null) {
$qb
->andWhere($qb->expr()->eq('card_id', (string)$cardId, IQueryBuilder::PARAM_INT));
}
$entities = [];
$cursor = $qb->execute();