Add date_modification to comments (PR #2950)
This commit is contained in:
parent
67aca3c664
commit
8e18c39db9
|
|
@ -60,6 +60,7 @@ class CommentModel extends Base
|
|||
->columns(
|
||||
self::TABLE.'.id',
|
||||
self::TABLE.'.date_creation',
|
||||
self::TABLE.'.date_modification',
|
||||
self::TABLE.'.task_id',
|
||||
self::TABLE.'.user_id',
|
||||
self::TABLE.'.comment',
|
||||
|
|
@ -69,7 +70,7 @@ class CommentModel extends Base
|
|||
UserModel::TABLE.'.avatar_path'
|
||||
)
|
||||
->join(UserModel::TABLE, 'id', 'user_id')
|
||||
->orderBy(self::TABLE.'.date_creation', $sorting)
|
||||
->orderBy(self::TABLE.'.date_modification', $sorting)
|
||||
->eq(self::TABLE.'.task_id', $task_id)
|
||||
->findAll();
|
||||
}
|
||||
|
|
@ -90,6 +91,7 @@ class CommentModel extends Base
|
|||
self::TABLE.'.task_id',
|
||||
self::TABLE.'.user_id',
|
||||
self::TABLE.'.date_creation',
|
||||
self::TABLE.'.date_modification',
|
||||
self::TABLE.'.comment',
|
||||
self::TABLE.'.reference',
|
||||
UserModel::TABLE.'.username',
|
||||
|
|
@ -127,6 +129,7 @@ class CommentModel extends Base
|
|||
public function create(array $values)
|
||||
{
|
||||
$values['date_creation'] = time();
|
||||
$values['date_modification'] = time();
|
||||
$comment_id = $this->db->table(self::TABLE)->persist($values);
|
||||
|
||||
if ($comment_id !== false) {
|
||||
|
|
@ -148,7 +151,7 @@ class CommentModel extends Base
|
|||
$result = $this->db
|
||||
->table(self::TABLE)
|
||||
->eq('id', $values['id'])
|
||||
->update(array('comment' => $values['comment']));
|
||||
->update(array('comment' => $values['comment'], 'date_modification' => time()));
|
||||
|
||||
if ($result) {
|
||||
$this->queueManager->push($this->commentEventJob->withParams($values['id'], self::EVENT_UPDATE));
|
||||
|
|
|
|||
|
|
@ -6,7 +6,15 @@ use PDO;
|
|||
use Kanboard\Core\Security\Token;
|
||||
use Kanboard\Core\Security\Role;
|
||||
|
||||
const VERSION = 118;
|
||||
const VERSION = 119;
|
||||
|
||||
function version_119(PDO $pdo)
|
||||
{
|
||||
$pdo->exec('ALTER TABLE `comments` ADD COLUMN `date_modification` BIGINT(20)');
|
||||
$pdo->exec('UPDATE `comments`
|
||||
SET `date_modification` = `date_creation`
|
||||
WHERE `date_modification` IS NULL');
|
||||
}
|
||||
|
||||
function version_118(PDO $pdo)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -6,7 +6,15 @@ use PDO;
|
|||
use Kanboard\Core\Security\Token;
|
||||
use Kanboard\Core\Security\Role;
|
||||
|
||||
const VERSION = 97;
|
||||
const VERSION = 98;
|
||||
|
||||
function version_98(PDO $pdo)
|
||||
{
|
||||
$pdo->exec('ALTER TABLE "comments" ADD COLUMN date_modification BIGINT');
|
||||
$pdo->exec('UPDATE "comments"
|
||||
SET date_modificaiton = date_creation
|
||||
WHERE date_modification IS NULL');
|
||||
}
|
||||
|
||||
function version_97(PDO $pdo)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -98,6 +98,7 @@ CREATE TABLE `comments` (
|
|||
`task_id` int(11) NOT NULL,
|
||||
`user_id` int(11) DEFAULT '0',
|
||||
`date_creation` bigint(20) DEFAULT NULL,
|
||||
`date_modification` bigint(20) DEFAULT NULL,
|
||||
`comment` text,
|
||||
`reference` varchar(50) DEFAULT '',
|
||||
PRIMARY KEY (`id`),
|
||||
|
|
@ -768,4 +769,4 @@ UNLOCK TABLES;
|
|||
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
|
||||
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
||||
|
||||
INSERT INTO users (username, password, role) VALUES ('admin', '$2y$10$R1zYk04d96KcHRpd9.r5I.5I6mgKIgUdsaISZYmaDLPIJCUO0FFJG', 'app-admin');INSERT INTO schema_version VALUES ('118');
|
||||
INSERT INTO users (username, password, role) VALUES ('admin', '$2y$10$R1zYk04d96KcHRpd9.r5I.5I6mgKIgUdsaISZYmaDLPIJCUO0FFJG', 'app-admin');INSERT INTO schema_version VALUES ('119');
|
||||
|
|
|
|||
|
|
@ -195,6 +195,7 @@ CREATE TABLE "comments" (
|
|||
"task_id" integer NOT NULL,
|
||||
"user_id" integer DEFAULT 0,
|
||||
"date_creation" bigint NOT NULL,
|
||||
"date_modification" bigint NOT NULL,
|
||||
"comment" "text",
|
||||
"reference" character varying(50) DEFAULT ''::character varying
|
||||
);
|
||||
|
|
@ -2613,4 +2614,4 @@ SELECT pg_catalog.setval('links_id_seq', 11, true);
|
|||
-- PostgreSQL database dump complete
|
||||
--
|
||||
|
||||
INSERT INTO users (username, password, role) VALUES ('admin', '$2y$10$0.8BJyhOEBHGqfwD3nIJHuxObqTlZGJ/KRNDVHfSu7RGd42rEbSa.', 'app-admin');INSERT INTO schema_version VALUES ('97');
|
||||
INSERT INTO users (username, password, role) VALUES ('admin', '$2y$10$0.8BJyhOEBHGqfwD3nIJHuxObqTlZGJ/KRNDVHfSu7RGd42rEbSa.', 'app-admin');INSERT INTO schema_version VALUES ('98');
|
||||
|
|
|
|||
|
|
@ -6,7 +6,15 @@ use Kanboard\Core\Security\Token;
|
|||
use Kanboard\Core\Security\Role;
|
||||
use PDO;
|
||||
|
||||
const VERSION = 108;
|
||||
const VERSION = 109;
|
||||
|
||||
function version_109(PDO $pdo)
|
||||
{
|
||||
$pdo->exec('ALTER TABLE comments ADD COLUMN date_modification INTEGER');
|
||||
$pdo->exec('UPDATE comments
|
||||
SET date_modification = date_creation
|
||||
WHERE date_modification IS NULL;');
|
||||
}
|
||||
|
||||
function version_108(PDO $pdo)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -7,7 +7,9 @@
|
|||
<strong class="comment-username"><?= $this->text->e($comment['name'] ?: $comment['username']) ?></strong>
|
||||
<?php endif ?>
|
||||
|
||||
<small class="comment-date"><?= $this->dt->datetime($comment['date_creation']) ?></small>
|
||||
<small class="comment-date"><?= t('Created At')?>: <?= $this->dt->datetime($comment['date_creation']) ?></small>
|
||||
<small class="comment-date"><?= t('Updated At')?>: <?= $this->dt->datetime($comment['date_modification']) ?></small>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="comment-content">
|
||||
|
|
|
|||
|
|
@ -35,10 +35,12 @@ class CommentProcedureTest extends BaseProcedureTest
|
|||
$this->assertNotEmpty($comment);
|
||||
$this->assertEquals(1, $comment['user_id']);
|
||||
$this->assertEquals('foobar', $comment['comment']);
|
||||
$this->assertEquals($comment['date_creation'], $comment['date_modification']);
|
||||
}
|
||||
|
||||
public function assertUpdateComment()
|
||||
{
|
||||
sleep(1); // Integration test fails because its too fast
|
||||
$this->assertTrue($this->app->execute('updateComment', array(
|
||||
'id' => $this->commentId,
|
||||
'content' => 'test',
|
||||
|
|
@ -46,6 +48,7 @@ class CommentProcedureTest extends BaseProcedureTest
|
|||
|
||||
$comment = $this->app->getComment($this->commentId);
|
||||
$this->assertEquals('test', $comment['comment']);
|
||||
$this->assertNotEquals($comment['date_creation'], $comment['date_modification']);
|
||||
}
|
||||
|
||||
public function assertGetAllComments()
|
||||
|
|
|
|||
|
|
@ -10,4 +10,4 @@
|
|||
<const name="DB_PASSWORD" value="" />
|
||||
<const name="DB_NAME" value="kanboard_unit_test" />
|
||||
</php>
|
||||
</phpunit>
|
||||
</phpunit>
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ class CommentModelTest extends Base
|
|||
$this->assertEquals(1, $comment['user_id']);
|
||||
$this->assertEquals('admin', $comment['username']);
|
||||
$this->assertEquals(time(), $comment['date_creation'], '', 3);
|
||||
$this->assertEquals(time(), $comment['date_modification'], '', 3);
|
||||
|
||||
$comment = $commentModel->getById(2);
|
||||
$this->assertNotEmpty($comment);
|
||||
|
|
@ -34,6 +35,7 @@ class CommentModelTest extends Base
|
|||
$this->assertEquals(0, $comment['user_id']);
|
||||
$this->assertEquals('', $comment['username']);
|
||||
$this->assertEquals(time(), $comment['date_creation'], '', 3);
|
||||
$this->assertEquals(time(), $comment['date_modification'], '', 3);
|
||||
}
|
||||
|
||||
public function testGetAll()
|
||||
|
|
@ -73,6 +75,7 @@ class CommentModelTest extends Base
|
|||
$comment = $commentModel->getById(1);
|
||||
$this->assertNotEmpty($comment);
|
||||
$this->assertEquals('bla', $comment['comment']);
|
||||
$this->assertEquals(time(), $comment['date_modification'], '', 3);
|
||||
}
|
||||
|
||||
public function testRemove()
|
||||
|
|
|
|||
Loading…
Reference in New Issue