aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_reminders/lib
diff options
context:
space:
mode:
authorChristopher Ng <chrng8@gmail.com>2023-07-31 12:10:50 -0700
committerChristopher Ng <chrng8@gmail.com>2023-08-03 15:30:11 -0700
commit4fabd7743230be80f82543edd4905ead97f14a59 (patch)
tree7d09b81d1a6bac9e999b131befd784f500ee91e6 /apps/files_reminders/lib
parent163b059c112d7c5eceb8a1cc1db55184855903df (diff)
downloadnextcloud-server-4fabd7743230be80f82543edd4905ead97f14a59.tar.gz
nextcloud-server-4fabd7743230be80f82543edd4905ead97f14a59.zip
enh: add created at
Signed-off-by: Christopher Ng <chrng8@gmail.com>
Diffstat (limited to 'apps/files_reminders/lib')
-rw-r--r--apps/files_reminders/lib/Command/ListCommand.php3
-rw-r--r--apps/files_reminders/lib/Db/Reminder.php5
-rw-r--r--apps/files_reminders/lib/Db/ReminderMapper.php14
-rw-r--r--apps/files_reminders/lib/Migration/Version10000Date20230725162149.php5
4 files changed, 18 insertions, 9 deletions
diff --git a/apps/files_reminders/lib/Command/ListCommand.php b/apps/files_reminders/lib/Command/ListCommand.php
index f284be5bf2a..074aeb87239 100644
--- a/apps/files_reminders/lib/Command/ListCommand.php
+++ b/apps/files_reminders/lib/Command/ListCommand.php
@@ -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,
diff --git a/apps/files_reminders/lib/Db/Reminder.php b/apps/files_reminders/lib/Db/Reminder.php
index fd20fb45f46..1abaa48d200 100644
--- a/apps/files_reminders/lib/Db/Reminder.php
+++ b/apps/files_reminders/lib/Db/Reminder.php
@@ -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');
}
}
diff --git a/apps/files_reminders/lib/Db/ReminderMapper.php b/apps/files_reminders/lib/Db/ReminderMapper.php
index 6b2e3a1f2b8..4d1ebab35b1 100644
--- a/apps/files_reminders/lib/Db/ReminderMapper.php
+++ b/apps/files_reminders/lib/Db/ReminderMapper.php
@@ -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')
diff --git a/apps/files_reminders/lib/Migration/Version10000Date20230725162149.php b/apps/files_reminders/lib/Migration/Version10000Date20230725162149.php
index 6a8cb783931..1940d153763 100644
--- a/apps/files_reminders/lib/Migration/Version10000Date20230725162149.php
+++ b/apps/files_reminders/lib/Migration/Version10000Date20230725162149.php
@@ -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,