summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/files_reminders/lib/Db/ReminderMapper.php4
-rw-r--r--apps/files_reminders/lib/Service/ReminderService.php5
2 files changed, 7 insertions, 2 deletions
diff --git a/apps/files_reminders/lib/Db/ReminderMapper.php b/apps/files_reminders/lib/Db/ReminderMapper.php
index 97f7ed0900b..1a8f05a3db9 100644
--- a/apps/files_reminders/lib/Db/ReminderMapper.php
+++ b/apps/files_reminders/lib/Db/ReminderMapper.php
@@ -26,6 +26,7 @@ declare(strict_types=1);
namespace OCA\FilesReminders\Db;
+use DateTime;
use OCP\AppFramework\Db\DoesNotExistException;
use OCP\AppFramework\Db\QBMapper;
use OCP\DB\QueryBuilder\IQueryBuilder;
@@ -138,12 +139,13 @@ class ReminderMapper extends QBMapper {
/**
* @return Reminder[]
*/
- public function findNotified(?int $limit = null) {
+ public function findNotified(DateTime $buffer, ?int $limit = null) {
$qb = $this->db->getQueryBuilder();
$qb->select('id', 'user_id', 'file_id', 'due_date', 'updated_at', 'created_at', 'notified')
->from($this->getTableName())
->where($qb->expr()->eq('notified', $qb->createNamedParameter(true, IQueryBuilder::PARAM_BOOL)))
+ ->andWhere($qb->expr()->lt('due_date', $qb->createNamedParameter($buffer, IQueryBuilder::PARAM_DATE)))
->orderBy('due_date', 'ASC')
->setMaxResults($limit);
diff --git a/apps/files_reminders/lib/Service/ReminderService.php b/apps/files_reminders/lib/Service/ReminderService.php
index 5c7193259c1..010f458e872 100644
--- a/apps/files_reminders/lib/Service/ReminderService.php
+++ b/apps/files_reminders/lib/Service/ReminderService.php
@@ -167,7 +167,10 @@ class ReminderService {
}
public function cleanUp(?int $limit = null): void {
- $reminders = $this->reminderMapper->findNotified($limit);
+ $buffer = (new DateTime())
+ ->setTimezone(new DateTimeZone('UTC'))
+ ->modify('-1 day');
+ $reminders = $this->reminderMapper->findNotified($buffer, $limit);
foreach ($reminders as $reminder) {
$this->reminderMapper->delete($reminder);
}