Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions apps/files_reminders/lib/Db/ReminderMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
declare(strict_types=1);

/**
* SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2023-2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

Expand All @@ -12,6 +12,7 @@
use DateTime;
use OCP\AppFramework\Db\DoesNotExistException;
use OCP\AppFramework\Db\QBMapper;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\Files\Folder;
use OCP\Files\Node;
Expand All @@ -25,12 +26,11 @@
class ReminderMapper extends QBMapper {
public const TABLE_NAME = 'files_reminders';

public function __construct(IDBConnection $db) {
parent::__construct(
$db,
static::TABLE_NAME,
Reminder::class,
);
public function __construct(
IDBConnection $db,
private ITimeFactory $timeFactory,
) {
parent::__construct($db, self::TABLE_NAME, Reminder::class);
}

public function markNotified(Reminder $reminder): Reminder {
Expand Down Expand Up @@ -108,9 +108,18 @@ public function findAllForNode(Node $node) {
public function findOverdue() {
$qb = $this->db->getQueryBuilder();

$now = $this->timeFactory->getDateTime();
$now->setTimezone(new \DateTimeZone('UTC'));

$qb->select('id', 'user_id', 'file_id', 'due_date', 'updated_at', 'created_at', 'notified')
->from($this->getTableName())
->where($qb->expr()->lt('due_date', $qb->createFunction('NOW()')))
->where(
$qb->expr()->lt(
'due_date',
$qb->createNamedParameter($now, IQueryBuilder::PARAM_DATETIME_MUTABLE),
IQueryBuilder::PARAM_DATETIME_MUTABLE,
)
)
->andWhere($qb->expr()->eq('notified', $qb->createNamedParameter(false, IQueryBuilder::PARAM_BOOL)))
->orderBy('due_date', 'ASC');

Expand Down
Loading