summaryrefslogtreecommitdiff
path: root/app/Model/Transition.php
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-05-28 19:48:22 -0400
committerFrederic Guillot <fred@kanboard.net>2016-05-28 19:48:22 -0400
commit14713b0ec7ed93ca45578da069ad4e19a7d8addf (patch)
tree79972d53f6091a1ddb17f64a6a05a5523f5d5168 /app/Model/Transition.php
parent936376ffe74c583d3cb819e98f53a85137fdf8bc (diff)
Rename all models
Diffstat (limited to 'app/Model/Transition.php')
-rw-r--r--app/Model/Transition.php130
1 files changed, 0 insertions, 130 deletions
diff --git a/app/Model/Transition.php b/app/Model/Transition.php
deleted file mode 100644
index 2bc622b0..00000000
--- a/app/Model/Transition.php
+++ /dev/null
@@ -1,130 +0,0 @@
-<?php
-
-namespace Kanboard\Model;
-
-use Kanboard\Core\Base;
-
-/**
- * Transition
- *
- * @package model
- * @author Frederic Guillot
- */
-class Transition extends Base
-{
- /**
- * SQL table name
- *
- * @var string
- */
- const TABLE = 'transitions';
-
- /**
- * Save transition event
- *
- * @access public
- * @param integer $user_id
- * @param array $task_event
- * @return bool
- */
- public function save($user_id, array $task_event)
- {
- $time = time();
-
- return $this->db->table(self::TABLE)->insert(array(
- 'user_id' => $user_id,
- 'project_id' => $task_event['project_id'],
- 'task_id' => $task_event['task_id'],
- 'src_column_id' => $task_event['src_column_id'],
- 'dst_column_id' => $task_event['dst_column_id'],
- 'date' => $time,
- 'time_spent' => $time - $task_event['date_moved']
- ));
- }
-
- /**
- * Get time spent by task for each column
- *
- * @access public
- * @param integer $task_id
- * @return array
- */
- public function getTimeSpentByTask($task_id)
- {
- return $this->db
- ->hashtable(self::TABLE)
- ->groupBy('src_column_id')
- ->eq('task_id', $task_id)
- ->getAll('src_column_id', 'SUM(time_spent) AS time_spent');
- }
-
- /**
- * 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(Column::TABLE.' as src', 'id', 'src_column_id', self::TABLE, 'src')
- ->join(Column::TABLE.' as dst', 'id', 'dst_column_id', self::TABLE, 'dst')
- ->findAll();
- }
-
- /**
- * Get all transitions by project
- *
- * @access public
- * @param integer $project_id
- * @param mixed $from Start date (timestamp or user formatted date)
- * @param mixed $to End date (timestamp or user formatted date)
- * @return array
- */
- public function getAllByProjectAndDate($project_id, $from, $to)
- {
- if (! is_numeric($from)) {
- $from = $this->dateParser->removeTimeFromTimestamp($this->dateParser->getTimestamp($from));
- }
-
- if (! is_numeric($to)) {
- $to = $this->dateParser->removeTimeFromTimestamp(strtotime('+1 day', $this->dateParser->getTimestamp($to)));
- }
-
- return $this->db->table(self::TABLE)
- ->columns(
- Task::TABLE.'.id',
- Task::TABLE.'.title',
- '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'
- )
- ->gte('date', $from)
- ->lte('date', $to)
- ->eq(self::TABLE.'.project_id', $project_id)
- ->desc('date')
- ->desc(self::TABLE.'.id')
- ->join(Task::TABLE, 'id', 'task_id')
- ->join(User::TABLE, 'id', 'user_id')
- ->join(Column::TABLE.' as src', 'id', 'src_column_id', self::TABLE, 'src')
- ->join(Column::TABLE.' as dst', 'id', 'dst_column_id', self::TABLE, 'dst')
- ->findAll();
- }
-}