aboutsummaryrefslogtreecommitdiffstats
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
commit5ff178a753c335d2ab6d10cee531490f1026ec42 (patch)
treecc478dd03b0ecfb52718080516e38a680d08ef7c
parent7637bf2ae04d5558b5771b62cd17b6bc7321ba44 (diff)
downloadnextcloud-server-5ff178a753c335d2ab6d10cee531490f1026ec42.tar.gz
nextcloud-server-5ff178a753c335d2ab6d10cee531490f1026ec42.zip
enh: add updated at
Signed-off-by: Christopher Ng <chrng8@gmail.com>
-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.php3
-rw-r--r--apps/files_reminders/lib/Model/RichReminder.php1
5 files changed, 18 insertions, 8 deletions
diff --git a/apps/files_reminders/lib/Command/ListCommand.php b/apps/files_reminders/lib/Command/ListCommand.php
index 7d6044f21c6..b066c6ed8cf 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', 'DueDate', 'CreatedAt', 'Notified'],
+ ['User Id', 'Path', 'Due Date', 'Updated At', 'Created At', 'Notified'],
array_map(
fn (RichReminder $reminder) => [
$reminder->getUserId(),
$reminder->getNode()->getPath(),
$reminder->getDueDate()->format(DateTimeInterface::ATOM), // ISO 8601
+ $reminder->getUpdatedAt()->format(DateTimeInterface::ATOM), // ISO 8601
$reminder->getCreatedAt()->format(DateTimeInterface::ATOM), // ISO 8601
$reminder->getNotified() ? 'true' : 'false',
],
diff --git a/apps/files_reminders/lib/Db/Reminder.php b/apps/files_reminders/lib/Db/Reminder.php
index 3a3641644f7..36f967f1434 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 setDueDate(DateTime $dueDate)
* @method DateTime getDueDate()
*
+ * @method void setUpdatedAt(DateTime $updatedAt)
+ * @method DateTime getUpdatedAt()
+ *
* @method void setCreatedAt(DateTime $createdAt)
* @method DateTime getCreatedAt()
*
@@ -49,6 +52,7 @@ class Reminder extends Entity {
protected $userId;
protected $fileId;
protected $dueDate;
+ protected $updatedAt;
protected $createdAt;
protected $notified = false;
@@ -56,6 +60,7 @@ class Reminder extends Entity {
$this->addType('userId', 'string');
$this->addType('fileId', 'integer');
$this->addType('dueDate', 'datetime');
+ $this->addType('updatedAt', '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 42208270262..4ddea3b303c 100644
--- a/apps/files_reminders/lib/Db/ReminderMapper.php
+++ b/apps/files_reminders/lib/Db/ReminderMapper.php
@@ -56,7 +56,7 @@ class ReminderMapper extends QBMapper {
public function find(int $id): Reminder {
$qb = $this->db->getQueryBuilder();
- $qb->select('user_id', 'file_id', 'due_date', 'created_at', 'notified')
+ $qb->select('user_id', 'file_id', 'due_date', 'updated_at', 'created_at', 'notified')
->from($this->getTableName())
->where($qb->expr()->eq('id', $qb->createNamedParameter($id, IQueryBuilder::PARAM_INT)));
@@ -69,12 +69,12 @@ class ReminderMapper extends QBMapper {
public function findDueForUser(IUser $user, int $fileId): Reminder {
$qb = $this->db->getQueryBuilder();
- $qb->select('user_id', 'file_id', 'due_date', 'created_at', 'notified')
+ $qb->select('user_id', 'file_id', 'due_date', 'updated_at', 'created_at', 'notified')
->from($this->getTableName())
->where($qb->expr()->eq('user_id', $qb->createNamedParameter($user->getUID(), IQueryBuilder::PARAM_STR)))
->andWhere($qb->expr()->eq('file_id', $qb->createNamedParameter($fileId, IQueryBuilder::PARAM_INT)))
->andWhere($qb->expr()->eq('notified', $qb->createNamedParameter(false, IQueryBuilder::PARAM_BOOL)))
- ->orderBy('created_at', 'DESC')
+ ->orderBy('updated_at', 'DESC')
->setMaxResults(1);
return $this->findEntity($qb);
@@ -86,7 +86,7 @@ class ReminderMapper extends QBMapper {
public function findAll() {
$qb = $this->db->getQueryBuilder();
- $qb->select('user_id', 'file_id', 'due_date', 'created_at', 'notified')
+ $qb->select('user_id', 'file_id', 'due_date', 'updated_at', 'created_at', 'notified')
->from($this->getTableName())
->orderBy('due_date', 'ASC');
@@ -99,7 +99,7 @@ class ReminderMapper extends QBMapper {
public function findAllForUser(IUser $user) {
$qb = $this->db->getQueryBuilder();
- $qb->select('user_id', 'file_id', 'due_date', 'created_at', 'notified')
+ $qb->select('user_id', 'file_id', 'due_date', 'updated_at', 'created_at', 'notified')
->from($this->getTableName())
->where($qb->expr()->eq('user_id', $qb->createNamedParameter($user->getUID(), IQueryBuilder::PARAM_STR)))
->orderBy('due_date', 'ASC');
@@ -113,7 +113,7 @@ class ReminderMapper extends QBMapper {
public function findOverdue() {
$qb = $this->db->getQueryBuilder();
- $qb->select('user_id', 'file_id', 'due_date', 'created_at', 'notified')
+ $qb->select('user_id', 'file_id', 'due_date', 'updated_at', 'created_at', 'notified')
->from($this->getTableName())
->where($qb->expr()->lt('due_date', $qb->createFunction('NOW()')))
->andWhere($qb->expr()->eq('notified', $qb->createNamedParameter(false, IQueryBuilder::PARAM_BOOL)))
@@ -128,7 +128,7 @@ class ReminderMapper extends QBMapper {
public function findNotified(?int $limit = null) {
$qb = $this->db->getQueryBuilder();
- $qb->select('user_id', 'file_id', 'due_date', 'created_at', 'notified')
+ $qb->select('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)))
->orderBy('due_date', 'ASC')
diff --git a/apps/files_reminders/lib/Migration/Version10000Date20230725162149.php b/apps/files_reminders/lib/Migration/Version10000Date20230725162149.php
index 20b9331fc66..0b7505d64e3 100644
--- a/apps/files_reminders/lib/Migration/Version10000Date20230725162149.php
+++ b/apps/files_reminders/lib/Migration/Version10000Date20230725162149.php
@@ -60,6 +60,9 @@ class Version10000Date20230725162149 extends SimpleMigrationStep {
$table->addColumn('due_date', Types::DATETIME, [
'notnull' => true,
]);
+ $table->addColumn('updated_at', Types::DATETIME, [
+ 'notnull' => true,
+ ]);
$table->addColumn('created_at', Types::DATETIME, [
'notnull' => true,
]);
diff --git a/apps/files_reminders/lib/Model/RichReminder.php b/apps/files_reminders/lib/Model/RichReminder.php
index 9f7e3f36556..1ac1baae370 100644
--- a/apps/files_reminders/lib/Model/RichReminder.php
+++ b/apps/files_reminders/lib/Model/RichReminder.php
@@ -67,6 +67,7 @@ class RichReminder extends Reminder implements JsonSerializable {
'userId' => $this->getUserId(),
'fileId' => $this->getFileId(),
'dueDate' => $this->getDueDate()->format(DateTimeInterface::ATOM), // ISO 8601
+ 'updatedAt' => $this->getUpdatedAt()->format(DateTimeInterface::ATOM), // ISO 8601
'createdAt' => $this->getCreatedAt()->format(DateTimeInterface::ATOM), // ISO 8601
'notified' => $this->getNotified(),
];