summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBlueTeck <tili2@gmx.de>2015-02-09 20:01:01 +0100
committerFrederic Guillot <fred@kanboard.net>2015-02-09 20:48:13 -0500
commit3704e33c668a63868efec504e3999a9edd123665 (patch)
tree9bf1443e6ce8755833a4f66c306d0829e71a459e
parent45b3cb0ccc54fa8beeac5e41ccadcc857e21d70c (diff)
added getProjectActivity + getOverdueTasks to API
-rw-r--r--app/Model/ProjectActivity.php25
-rw-r--r--jsonrpc.php2
2 files changed, 21 insertions, 6 deletions
diff --git a/app/Model/ProjectActivity.php b/app/Model/ProjectActivity.php
index 8ef35a97..7762d0fd 100644
--- a/app/Model/ProjectActivity.php
+++ b/app/Model/ProjectActivity.php
@@ -56,11 +56,13 @@ class ProjectActivity extends Base
* @access public
* @param integer $project_id Project id
* @param integer $limit Maximum events number
+ * @param integer $start Timestamp of earliest activity
+ * @param integer $end Timestamp of latest activity
* @return array
*/
- public function getProject($project_id, $limit = 50)
+ public function getProject($project_id, $limit = 50, $start = null, $end = null)
{
- return $this->getProjects(array($project_id), $limit);
+ return $this->getProjects(array($project_id), $limit, $start = null, $end = null);
}
/**
@@ -69,15 +71,17 @@ class ProjectActivity extends Base
* @access public
* @param integer[] $project_ids Projects id
* @param integer $limit Maximum events number
+ * @param integer $start Timestamp of earliest activity
+ * @param integer $end Timestamp of latest activity
* @return array
*/
- public function getProjects(array $project_ids, $limit = 50)
+ public function getProjects(array $project_ids, $limit = 50, $start = null, $end = null)
{
if (empty($project_ids)) {
return array();
}
- $events = $this->db->table(self::TABLE)
+ $query = $this->db->table(self::TABLE)
->columns(
self::TABLE.'.*',
User::TABLE.'.username AS author_username',
@@ -86,8 +90,17 @@ class ProjectActivity extends Base
->in('project_id', $project_ids)
->join(User::TABLE, 'id', 'creator_id')
->desc(self::TABLE.'.id')
- ->limit($limit)
- ->findAll();
+ ->limit($limit);
+
+ if(!is_null($start)){
+ $query->gte('date_creation', $start);
+ }
+
+ if(!is_null($end)){
+ $query->lte('date_creation', $end);
+ }
+
+ $events = $query->findAll();
foreach ($events as &$event) {
diff --git a/jsonrpc.php b/jsonrpc.php
index 6530e73a..566976cd 100644
--- a/jsonrpc.php
+++ b/jsonrpc.php
@@ -20,6 +20,7 @@ $server->bind('enableProject', $container['project'], 'enable');
$server->bind('disableProject', $container['project'], 'disable');
$server->bind('enableProjectPublicAccess', $container['project'], 'enablePublicAccess');
$server->bind('disableProjectPublicAccess', $container['project'], 'disablePublicAccess');
+$server->bind('getProjectActivity', $container['projectActivity'], 'getProjects');
$server->register('createProject', function($name) use ($container) {
$values = array('name' => $name);
@@ -71,6 +72,7 @@ $server->bind('allowUser', $container['projectPermission'], 'addMember');
*/
$server->bind('getTask', $container['taskFinder'], 'getById');
$server->bind('getAllTasks', $container['taskFinder'], 'getAll');
+$server->bind('getOverdueTasks', $container['taskFinder'], 'getOverdueTasks');
$server->bind('openTask', $container['taskStatus'], 'open');
$server->bind('closeTask', $container['taskStatus'], 'close');
$server->bind('removeTask', $container['task'], 'remove');