]> source.dussan.org Git - nextcloud-server.git/commitdiff
enh: add created at
authorChristopher Ng <chrng8@gmail.com>
Mon, 31 Jul 2023 19:10:50 +0000 (12:10 -0700)
committerChristopher Ng <chrng8@gmail.com>
Thu, 3 Aug 2023 22:30:11 +0000 (15:30 -0700)
Signed-off-by: Christopher Ng <chrng8@gmail.com>
apps/files_reminders/lib/Command/ListCommand.php
apps/files_reminders/lib/Db/Reminder.php
apps/files_reminders/lib/Db/ReminderMapper.php
apps/files_reminders/lib/Migration/Version10000Date20230725162149.php

index f284be5bf2a5f7f9b6167045b15c03c8d905007a..074aeb87239015b991c73e9329e5c01ec342643e 100644 (file)
@@ -75,12 +75,13 @@ class ListCommand extends Base {
                }
 
                $io->table(
-                       ['UserId', 'Path', 'RemindAt', 'Notified'],
+                       ['UserId', 'Path', 'RemindAt', 'CreatedAt', 'Notified'],
                        array_map(
                                fn (RichReminder $reminder) => [
                                        $reminder->getUserId(),
                                        $reminder->getNode()->getPath(),
                                        $reminder->getRemindAt()->format(DateTimeInterface::ATOM), // ISO 8601
+                                       $reminder->getCreatedAt()->format(DateTimeInterface::ATOM), // ISO 8601
                                        $reminder->getNotified() ? 'true' : 'false',
                                ],
                                $reminders,
index fd20fb45f4620940e84999d71fef9f450f4f3b13..1abaa48d2008ba88489c402cd28915b5b4414624 100644 (file)
@@ -39,6 +39,9 @@ use OCP\AppFramework\Db\Entity;
  * @method void setRemindAt(DateTime $remindAt)
  * @method DateTime getRemindAt()
  *
+ * @method void setCreatedAt(DateTime $createdAt)
+ * @method DateTime getCreatedAt()
+ *
  * @method void setNotified(bool $notified)
  * @method bool getNotified()
  */
@@ -46,12 +49,14 @@ class Reminder extends Entity {
        protected $userId;
        protected $fileId;
        protected $remindAt;
+       protected $createdAt;
        protected $notified = false;
 
        public function __construct() {
                $this->addType('userId', 'string');
                $this->addType('fileId', 'integer');
                $this->addType('remindAt', 'datetime');
+               $this->addType('createdAt', 'datetime');
                $this->addType('notified', 'boolean');
        }
 }
index 6b2e3a1f2b87cb3f6da56cf615990a7a79eddb94..4d1ebab35b141e2a4380e9d9b6bb37e20ff2b24c 100644 (file)
@@ -55,8 +55,8 @@ class ReminderMapper extends QBMapper {
        public function find(int $id): Reminder {
                $qb = $this->db->getQueryBuilder();
 
-               $qb->select('user_id', 'file_id', 'remind_at', 'notified')
-               ->from($this->getTableName())
+               $qb->select('user_id', 'file_id', 'remind_at', 'created_at', 'notified')
+                       ->from($this->getTableName())
                        ->where($qb->expr()->eq('id', $qb->createNamedParameter($id, IQueryBuilder::PARAM_INT)));
 
                return $this->findEntity($qb);
@@ -68,7 +68,7 @@ class ReminderMapper extends QBMapper {
        public function findAll() {
                $qb = $this->db->getQueryBuilder();
 
-               $qb->select('user_id', 'file_id', 'remind_at', 'notified')
+               $qb->select('user_id', 'file_id', 'remind_at', 'created_at', 'notified')
                        ->from($this->getTableName())
                        ->orderBy('remind_at', 'ASC');
 
@@ -81,8 +81,8 @@ class ReminderMapper extends QBMapper {
        public function findAllForUser(IUser $user) {
                $qb = $this->db->getQueryBuilder();
 
-               $qb->select('user_id', 'file_id', 'remind_at', 'notified')
-               ->from($this->getTableName())
+               $qb->select('user_id', 'file_id', 'remind_at', 'created_at', 'notified')
+                       ->from($this->getTableName())
                        ->where($qb->expr()->eq('user_id', $qb->createNamedParameter($user->getUID(), IQueryBuilder::PARAM_STR)))
                        ->orderBy('remind_at', 'ASC');
 
@@ -95,7 +95,7 @@ class ReminderMapper extends QBMapper {
        public function findToRemind() {
                $qb = $this->db->getQueryBuilder();
 
-               $qb->select('user_id', 'file_id', 'remind_at', 'notified')
+               $qb->select('user_id', 'file_id', 'remind_at', 'created_at', 'notified')
                        ->from($this->getTableName())
                        ->where($qb->expr()->lt('remind_at', $qb->createFunction('NOW()')))
                        ->andWhere($qb->expr()->eq('notified', $qb->createNamedParameter(false, IQueryBuilder::PARAM_BOOL)))
@@ -110,7 +110,7 @@ class ReminderMapper extends QBMapper {
        public function findToDelete(?int $limit = null) {
                $qb = $this->db->getQueryBuilder();
 
-               $qb->select('user_id', 'file_id', 'remind_at', 'notified')
+               $qb->select('user_id', 'file_id', 'remind_at', 'created_at', 'notified')
                        ->from($this->getTableName())
                        ->where($qb->expr()->eq('notified', $qb->createNamedParameter(true, IQueryBuilder::PARAM_BOOL)))
                        ->orderBy('remind_at', 'ASC')
index 6a8cb783931c5d342725f5bc5eade8f431273941..1940d153763eb350cb989535182f007271346896 100644 (file)
@@ -58,7 +58,10 @@ class Version10000Date20230725162149 extends SimpleMigrationStep {
                        'unsigned' => true,
                ]);
                $table->addColumn('remind_at', Types::DATETIME, [
-                       'notnull' => false,
+                       'notnull' => true,
+               ]);
+               $table->addColumn('created_at', Types::DATETIME, [
+                       'notnull' => true,
                ]);
                $table->addColumn('notified', Types::BOOLEAN, [
                        'notnull' => false,