summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog1
-rw-r--r--app/Model/TaskPosition.php10
-rw-r--r--app/ServiceProvider/EventDispatcherProvider.php1
-rw-r--r--app/Subscriber/TaskMovedDateSubscriber.php25
-rw-r--r--tests/units/Model/TaskMovedDateSubscriberTest.php77
5 files changed, 10 insertions, 104 deletions
diff --git a/ChangeLog b/ChangeLog
index f11edbac..46669325 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -14,6 +14,7 @@ Improvements:
* Move validators to a separate namespace
* Improve and write unit tests for reports
* Reduce the number of SQL queries for project daily column stats
+* Remove subscriber to update date_moved field
Bug fixes:
diff --git a/app/Model/TaskPosition.php b/app/Model/TaskPosition.php
index 53193c9b..762f7fe3 100644
--- a/app/Model/TaskPosition.php
+++ b/app/Model/TaskPosition.php
@@ -120,10 +120,18 @@ class TaskPosition extends Base
*/
private function updateTaskPosition($task_id, $swimlane_id, $column_id, $position)
{
+ $now = time();
+
return $this->db->table(Task::TABLE)
->eq('id', $task_id)
->eq('is_active', 1)
- ->update(array('position' => $position, 'column_id' => $column_id, 'swimlane_id' => $swimlane_id, 'date_modification' => time()));
+ ->update(array(
+ 'position' => $position,
+ 'column_id' => $column_id,
+ 'swimlane_id' => $swimlane_id,
+ 'date_modification' => $now,
+ 'date_moved' => $now,
+ ));
}
/**
diff --git a/app/ServiceProvider/EventDispatcherProvider.php b/app/ServiceProvider/EventDispatcherProvider.php
index 6cb302e6..8280a138 100644
--- a/app/ServiceProvider/EventDispatcherProvider.php
+++ b/app/ServiceProvider/EventDispatcherProvider.php
@@ -26,7 +26,6 @@ class EventDispatcherProvider implements ServiceProviderInterface
$container['dispatcher']->addSubscriber(new ProjectModificationDateSubscriber($container));
$container['dispatcher']->addSubscriber(new NotificationSubscriber($container));
$container['dispatcher']->addSubscriber(new SubtaskTimeTrackingSubscriber($container));
- $container['dispatcher']->addSubscriber(new TaskMovedDateSubscriber($container));
$container['dispatcher']->addSubscriber(new TransitionSubscriber($container));
$container['dispatcher']->addSubscriber(new RecurringTaskSubscriber($container));
diff --git a/app/Subscriber/TaskMovedDateSubscriber.php b/app/Subscriber/TaskMovedDateSubscriber.php
deleted file mode 100644
index 9857f4b3..00000000
--- a/app/Subscriber/TaskMovedDateSubscriber.php
+++ /dev/null
@@ -1,25 +0,0 @@
-<?php
-
-namespace Kanboard\Subscriber;
-
-use Kanboard\Event\TaskEvent;
-use Kanboard\Model\Task;
-use Symfony\Component\EventDispatcher\EventSubscriberInterface;
-
-class TaskMovedDateSubscriber extends \Kanboard\Core\Base implements EventSubscriberInterface
-{
- public static function getSubscribedEvents()
- {
- return array(
- Task::EVENT_MOVE_COLUMN => array('execute', 0),
- Task::EVENT_MOVE_SWIMLANE => array('execute', 0),
- );
- }
-
- public function execute(TaskEvent $event)
- {
- if (isset($event['task_id'])) {
- $this->container['db']->table(Task::TABLE)->eq('id', $event['task_id'])->update(array('date_moved' => time()));
- }
- }
-}
diff --git a/tests/units/Model/TaskMovedDateSubscriberTest.php b/tests/units/Model/TaskMovedDateSubscriberTest.php
deleted file mode 100644
index 0dd6e995..00000000
--- a/tests/units/Model/TaskMovedDateSubscriberTest.php
+++ /dev/null
@@ -1,77 +0,0 @@
-<?php
-
-require_once __DIR__.'/../Base.php';
-
-use Kanboard\Model\TaskPosition;
-use Kanboard\Model\TaskCreation;
-use Kanboard\Model\TaskFinder;
-use Kanboard\Model\Project;
-use Kanboard\Model\Swimlane;
-use Kanboard\Subscriber\TaskMovedDateSubscriber;
-use Symfony\Component\EventDispatcher\EventDispatcher;
-
-class TaskMovedDateSubscriberTest extends Base
-{
- public function testMoveTaskAnotherColumn()
- {
- $tp = new TaskPosition($this->container);
- $tc = new TaskCreation($this->container);
- $p = new Project($this->container);
- $tf = new TaskFinder($this->container);
-
- $this->container['dispatcher'] = new EventDispatcher;
- $this->container['dispatcher']->addSubscriber(new TaskMovedDateSubscriber($this->container));
-
- $now = time();
-
- $this->assertEquals(1, $p->create(array('name' => 'Project #1')));
- $this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1)));
-
- $task = $tf->getById(1);
- $this->assertNotEmpty($task);
- $this->assertEquals($now, $task['date_moved'], '', 1);
-
- sleep(1);
-
- $this->assertTrue($tp->movePosition(1, 1, 2, 1));
-
- $task = $tf->getById(1);
- $this->assertNotEmpty($task);
- $this->assertNotEquals($now, $task['date_moved']);
- }
-
- public function testMoveTaskAnotherSwimlane()
- {
- $tp = new TaskPosition($this->container);
- $tc = new TaskCreation($this->container);
- $p = new Project($this->container);
- $tf = new TaskFinder($this->container);
- $s = new Swimlane($this->container);
-
- $this->container['dispatcher'] = new EventDispatcher;
- $this->container['dispatcher']->addSubscriber(new TaskMovedDateSubscriber($this->container));
-
- $now = time();
-
- $this->assertEquals(1, $p->create(array('name' => 'Project #1')));
- $this->assertEquals(1, $s->create(array('project_id' => 1, 'name' => 'S1')));
- $this->assertEquals(2, $s->create(array('project_id' => 1, 'name' => 'S2')));
- $this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1)));
-
- $task = $tf->getById(1);
- $this->assertNotEmpty($task);
- $this->assertEquals($now, $task['date_moved'], '', 1);
- $this->assertEquals(1, $task['column_id']);
- $this->assertEquals(0, $task['swimlane_id']);
-
- sleep(1);
-
- $this->assertTrue($tp->movePosition(1, 1, 2, 1, 2));
-
- $task = $tf->getById(1);
- $this->assertNotEmpty($task);
- $this->assertNotEquals($now, $task['date_moved']);
- $this->assertEquals(2, $task['column_id']);
- $this->assertEquals(2, $task['swimlane_id']);
- }
-}