From 87d2c6d99e6eb26b526f5da22b3496e3d02d11ed Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Thu, 26 Mar 2015 22:40:46 -0400 Subject: Add task transitions history --- app/Model/Transition.php | 67 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 app/Model/Transition.php (limited to 'app/Model/Transition.php') diff --git a/app/Model/Transition.php b/app/Model/Transition.php new file mode 100644 index 00000000..583d3aca --- /dev/null +++ b/app/Model/Transition.php @@ -0,0 +1,67 @@ +db->table(self::TABLE)->insert(array( + 'user_id' => $user_id, + 'project_id' => $task['project_id'], + 'task_id' => $task['task_id'], + 'src_column_id' => $task['src_column_id'], + 'dst_column_id' => $task['dst_column_id'], + 'date' => time(), + 'time_spent' => time() - $task['date_moved'] + )); + } + + /** + * Get all transitions by task + * + * @access public + * @param integer $task_id + * @return array + */ + public function getAllByTask($task_id) + { + return $this->db->table(self::TABLE) + ->columns( + 'src.title as src_column', + 'dst.title as dst_column', + User::TABLE.'.name', + User::TABLE.'.username', + self::TABLE.'.user_id', + self::TABLE.'.date', + self::TABLE.'.time_spent' + ) + ->eq('task_id', $task_id) + ->desc('date') + ->join(User::TABLE, 'id', 'user_id') + ->join(Board::TABLE.' as src', 'id', 'src_column_id', self::TABLE, 'src') + ->join(Board::TABLE.' as dst', 'id', 'dst_column_id', self::TABLE, 'dst') + ->findAll(); + } +} -- cgit v1.2.3