summaryrefslogtreecommitdiff
path: root/app/Model
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2015-02-08 13:46:38 -0500
committerFrederic Guillot <fred@kanboard.net>2015-02-08 13:46:38 -0500
commit813b7c4c0036a73c3bb5ef31f98e83cce2630e9e (patch)
tree2374d6e4f07cda8f56f32b2997f3dc900ebbaa1d /app/Model
parent696cd9535cc622e477dde10eac24b947c351dc87 (diff)
Add unit test for subtask time tracking
Diffstat (limited to 'app/Model')
-rw-r--r--app/Model/SubtaskTimeTracking.php27
1 files changed, 25 insertions, 2 deletions
diff --git a/app/Model/SubtaskTimeTracking.php b/app/Model/SubtaskTimeTracking.php
index 3104dc20..5b58dfe2 100644
--- a/app/Model/SubtaskTimeTracking.php
+++ b/app/Model/SubtaskTimeTracking.php
@@ -44,6 +44,21 @@ class SubtaskTimeTracking extends Base
}
/**
+ * Get all recorded time slots for a given user
+ *
+ * @access public
+ * @param integer $user_id User id
+ * @return array
+ */
+ public function getUserTimesheet($user_id)
+ {
+ return $this->db
+ ->table(self::TABLE)
+ ->eq('user_id', $user_id)
+ ->findAll();
+ }
+
+ /**
* Log start time
*
* @access public
@@ -140,9 +155,17 @@ class SubtaskTimeTracking extends Base
->eq('end', 0)
->findOneColumn('start');
+ $time_spent = $this->db
+ ->table(Subtask::TABLE)
+ ->eq('id', $subtask_id)
+ ->findOneColumn('time_spent');
+
return $start_time &&
$this->db
- ->getConnection()
- ->exec('UPDATE '.Subtask::TABLE.' SET time_spent=time_spent+'.round((time() - $start_time) / 3600, 1).' WHERE id='.$subtask_id);
+ ->table(Subtask::TABLE)
+ ->eq('id', $subtask_id)
+ ->update(array(
+ 'time_spent' => $time_spent + round((time() - $start_time) / 3600, 1)
+ ));
}
}