aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_reminders/lib/Controller
diff options
context:
space:
mode:
authorChristopher Ng <chrng8@gmail.com>2025-01-24 14:27:53 -0800
committerPytal <24800714+Pytal@users.noreply.github.com>2025-02-21 14:03:01 -0800
commit802886d592547a66028b842cfb27662d879b639e (patch)
tree47c1b080d155d7485248ca9a732eb61e6df42333 /apps/files_reminders/lib/Controller
parent6cd30463699fda1dc0b9c2e99f497bdef56a293e (diff)
downloadnextcloud-server-802886d592547a66028b842cfb27662d879b639e.tar.gz
nextcloud-server-802886d592547a66028b842cfb27662d879b639e.zip
perf(files_reminders): Reduce db queries on propfind
Signed-off-by: Christopher Ng <chrng8@gmail.com>
Diffstat (limited to 'apps/files_reminders/lib/Controller')
-rw-r--r--apps/files_reminders/lib/Controller/ApiController.php19
1 files changed, 9 insertions, 10 deletions
diff --git a/apps/files_reminders/lib/Controller/ApiController.php b/apps/files_reminders/lib/Controller/ApiController.php
index ee29b7ce494..c95a74a04f4 100644
--- a/apps/files_reminders/lib/Controller/ApiController.php
+++ b/apps/files_reminders/lib/Controller/ApiController.php
@@ -14,8 +14,8 @@ use DateTimeInterface;
use DateTimeZone;
use Exception;
use OCA\FilesReminders\Exception\NodeNotFoundException;
+use OCA\FilesReminders\Exception\ReminderNotFoundException;
use OCA\FilesReminders\Service\ReminderService;
-use OCP\AppFramework\Db\DoesNotExistException;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
use OCP\AppFramework\Http\DataResponse;
@@ -53,15 +53,14 @@ class ApiController extends OCSController {
try {
$reminder = $this->reminderService->getDueForUser($user, $fileId);
- $reminderData = [
+ if ($reminder === null) {
+ return new DataResponse(['dueDate' => null], Http::STATUS_OK);
+ }
+ return new DataResponse([
'dueDate' => $reminder->getDueDate()->format(DateTimeInterface::ATOM), // ISO 8601
- ];
- return new DataResponse($reminderData, Http::STATUS_OK);
- } catch (NodeNotFoundException|DoesNotExistException $e) {
- $reminderData = [
- 'dueDate' => null,
- ];
- return new DataResponse($reminderData, Http::STATUS_OK);
+ ], Http::STATUS_OK);
+ } catch (NodeNotFoundException $e) {
+ return new DataResponse(['dueDate' => null], Http::STATUS_OK);
}
}
@@ -125,7 +124,7 @@ class ApiController extends OCSController {
try {
$this->reminderService->remove($user, $fileId);
return new DataResponse([], Http::STATUS_OK);
- } catch (NodeNotFoundException|DoesNotExistException $e) {
+ } catch (NodeNotFoundException|ReminderNotFoundException $e) {
return new DataResponse([], Http::STATUS_NOT_FOUND);
}
}