summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/Model/TaskCreation.php1
-rw-r--r--app/Model/TaskFinder.php2
-rw-r--r--app/Model/TaskPosition.php5
-rw-r--r--app/Schema/Mysql.php33
-rw-r--r--app/Schema/Postgres.php33
-rw-r--r--app/Schema/Sqlite.php33
-rw-r--r--app/Template/board/task.php5
7 files changed, 107 insertions, 5 deletions
diff --git a/app/Model/TaskCreation.php b/app/Model/TaskCreation.php
index 17e5ff70..893cbc43 100644
--- a/app/Model/TaskCreation.php
+++ b/app/Model/TaskCreation.php
@@ -62,6 +62,7 @@ class TaskCreation extends Base
$values['swimlane_id'] = empty($values['swimlane_id']) ? 0 : $values['swimlane_id'];
$values['date_creation'] = time();
$values['date_modification'] = $values['date_creation'];
+ $values['date_moved'] = $values['date_creation'];
$values['position'] = $this->taskFinder->countByColumnAndSwimlaneId($values['project_id'], $values['column_id'], $values['swimlane_id']) + 1;
}
diff --git a/app/Model/TaskFinder.php b/app/Model/TaskFinder.php
index 4ed196ef..05168593 100644
--- a/app/Model/TaskFinder.php
+++ b/app/Model/TaskFinder.php
@@ -102,6 +102,7 @@ class TaskFinder extends Base
'tasks.is_active',
'tasks.score',
'tasks.category_id',
+ 'tasks.date_moved',
'users.username AS assignee_username',
'users.name AS assignee_name'
)
@@ -242,6 +243,7 @@ class TaskFinder extends Base
tasks.score,
tasks.category_id,
tasks.swimlane_id,
+ tasks.date_moved,
project_has_categories.name AS category_name,
projects.name AS project_name,
columns.title AS column_title,
diff --git a/app/Model/TaskPosition.php b/app/Model/TaskPosition.php
index 2c271de7..9733999b 100644
--- a/app/Model/TaskPosition.php
+++ b/app/Model/TaskPosition.php
@@ -30,7 +30,10 @@ class TaskPosition extends Base
$result = $this->calculateAndSave($project_id, $task_id, $column_id, $position, $swimlane_id);
if ($result) {
-
+ if ($original_task['column_id'] != $column_id) {
+ $this->db->table(Task::TABLE)->eq('id', $task_id)->update(array('date_moved' => time(),
+ ));
+ }
if ($original_task['swimlane_id'] != $swimlane_id) {
$this->calculateAndSave($project_id, 0, $column_id, 1, $original_task['swimlane_id']);
}
diff --git a/app/Schema/Mysql.php b/app/Schema/Mysql.php
index 9c066625..e4be05b7 100644
--- a/app/Schema/Mysql.php
+++ b/app/Schema/Mysql.php
@@ -5,7 +5,38 @@ namespace Schema;
use PDO;
use Core\Security;
-const VERSION = 44;
+const VERSION = 45;
+
+function version_45($pdo)
+{
+ $pdo->exec('ALTER TABLE tasks ADD COLUMN date_moved INT DEFAULT 0');
+
+ /* Update tasks.date_moved from project_activities table if tasks.date_moved = null or 0.
+ * We take max project_activities.date_creation where event_name in task.create','task.move.column
+ * since creation date is always less than task moves
+ */
+ $pdo->exec("UPDATE tasks
+ SET date_moved = (
+ SELECT md
+ FROM (
+ SELECT task_id, max(date_creation) md
+ FROM project_activities
+ WHERE event_name IN ('task.create', 'task.move.column')
+ GROUP BY task_id
+ ) src
+ WHERE id = src.task_id
+ )
+ WHERE (date_moved IS NULL OR date_moved = 0) AND id IN (
+ SELECT task_id
+ FROM (
+ SELECT task_id, max(date_creation) md
+ FROM project_activities
+ WHERE event_name IN ('task.create', 'task.move.column')
+ GROUP BY task_id
+ ) src
+ )
+ ");
+}
function version_44($pdo)
{
diff --git a/app/Schema/Postgres.php b/app/Schema/Postgres.php
index 52130c96..92587273 100644
--- a/app/Schema/Postgres.php
+++ b/app/Schema/Postgres.php
@@ -5,7 +5,38 @@ namespace Schema;
use PDO;
use Core\Security;
-const VERSION = 25;
+const VERSION = 26;
+
+function version_26($pdo)
+{
+ $pdo->exec('ALTER TABLE tasks ADD COLUMN date_moved INT DEFAULT 0');
+
+ /* Update tasks.date_moved from project_activities table if tasks.date_moved = null or 0.
+ * We take max project_activities.date_creation where event_name in task.create','task.move.column
+ * since creation date is always less than task moves
+ */
+ $pdo->exec("UPDATE tasks
+ SET date_moved = (
+ SELECT md
+ FROM (
+ SELECT task_id, max(date_creation) md
+ FROM project_activities
+ WHERE event_name IN ('task.create', 'task.move.column')
+ GROUP BY task_id
+ ) src
+ WHERE id = src.task_id
+ )
+ WHERE (date_moved IS NULL OR date_moved = 0) AND id IN (
+ SELECT task_id
+ FROM (
+ SELECT task_id, max(date_creation) md
+ FROM project_activities
+ WHERE event_name IN ('task.create', 'task.move.column')
+ GROUP BY task_id
+ ) src
+ )
+ ");
+}
function version_25($pdo)
{
diff --git a/app/Schema/Sqlite.php b/app/Schema/Sqlite.php
index 37483945..7e0668e3 100644
--- a/app/Schema/Sqlite.php
+++ b/app/Schema/Sqlite.php
@@ -5,7 +5,38 @@ namespace Schema;
use Core\Security;
use PDO;
-const VERSION = 43;
+const VERSION = 44;
+
+function version_44($pdo)
+{
+ $pdo->exec('ALTER TABLE tasks ADD COLUMN date_moved INTEGER DEFAULT 0');
+
+ /* Update tasks.date_moved from project_activities table if tasks.date_moved = null or 0.
+ * We take max project_activities.date_creation where event_name in task.create','task.move.column
+ * since creation date is always less than task moves
+ */
+ $pdo->exec("UPDATE tasks
+ SET date_moved = (
+ SELECT md
+ FROM (
+ SELECT task_id, max(date_creation) md
+ FROM project_activities
+ WHERE event_name IN ('task.create', 'task.move.column')
+ GROUP BY task_id
+ ) src
+ WHERE id = src.task_id
+ )
+ WHERE (date_moved IS NULL OR date_moved = 0) AND id IN (
+ SELECT task_id
+ FROM (
+ SELECT task_id, max(date_creation) md
+ FROM project_activities
+ WHERE event_name IN ('task.create', 'task.move.column')
+ GROUP BY task_id
+ ) src
+ )
+ ");
+}
function version_43($pdo)
{
diff --git a/app/Template/board/task.php b/app/Template/board/task.php
index 41c7ab45..3d3fb269 100644
--- a/app/Template/board/task.php
+++ b/app/Template/board/task.php
@@ -68,7 +68,10 @@
t('Change assignee')
) ?>
</span>
-
+
+ <span title="<?= t('Task age in days')?>" class="task-days-age"><?= floor(time()/86400) - floor($task['date_creation']/86400)?>d</span>
+ <span title="<?= t('Days in this column')?>" class="task-days-incolumn"><?= floor(time()/86400) - floor($task['date_moved']/86400)?>d</span>
+
<?php if ($task['score']): ?>
<span class="task-score"><?= $this->e($task['score']) ?></span>
<?php endif ?>