diff options
author | Kamil <k.sciana@gmail.com> | 2018-07-19 21:22:21 +0200 |
---|---|---|
committer | Frédéric Guillot <fred@kanboard.net> | 2018-07-19 12:22:21 -0700 |
commit | 03a22132e430adc43845da9a6b5f2dacbeafd311 (patch) | |
tree | ed8da48670f0997e0c18c1f191e779d8f2de66aa /app/Filter | |
parent | fe935d6ec1e82bea1fd002ea19b6e2f9647ddc70 (diff) |
Add search within a range of dates for completion and modification
Diffstat (limited to 'app/Filter')
-rw-r--r-- | app/Filter/BaseDateRangeFilter.php | 8 | ||||
-rw-r--r-- | app/Filter/TaskCompletionDateRangeFilter.php | 38 | ||||
-rw-r--r-- | app/Filter/TaskModificationDateRangeFilter.php | 38 |
3 files changed, 80 insertions, 4 deletions
diff --git a/app/Filter/BaseDateRangeFilter.php b/app/Filter/BaseDateRangeFilter.php index 336f8c8e..fcff0d4c 100644 --- a/app/Filter/BaseDateRangeFilter.php +++ b/app/Filter/BaseDateRangeFilter.php @@ -42,10 +42,10 @@ abstract class BaseDateRangeFilter extends BaseFilter protected function applyDateFilter($field) { $dates = explode('..', $this->value); - - if(count($dates)=== 2){ - $timestampFrom = $this->dateParser->getTimestamp($dates[0]); - $timestampTo = $this->dateParser->getTimestamp($dates[1]); + + if(count($dates)=== 2){ + $timestampFrom = $this->dateParser->getTimestamp($dates[0]." 00:00"); + $timestampTo = $this->dateParser->getTimestamp($dates[1]." 00:00"); $this->query->gte($field, $timestampFrom); $this->query->lte($field, $timestampTo + 86399); diff --git a/app/Filter/TaskCompletionDateRangeFilter.php b/app/Filter/TaskCompletionDateRangeFilter.php new file mode 100644 index 00000000..9272cc1e --- /dev/null +++ b/app/Filter/TaskCompletionDateRangeFilter.php @@ -0,0 +1,38 @@ +<?php + +namespace Kanboard\Filter; + +use Kanboard\Core\Filter\FilterInterface; +use Kanboard\Model\TaskModel; + +/** + * Filter tasks by completion date + * + * @package filter + * @author Kamil Ściana + */ +class TaskCompletionDateRangeFilter extends BaseDateRangeFilter implements FilterInterface +{ + /** + * Get search attribute + * + * @access public + * @return string[] + */ + public function getAttributes() + { + return array('completedRange'); + } + + /** + * Apply filter + * + * @access public + * @return FilterInterface + */ + public function apply() + { + $this->applyDateFilter(TaskModel::TABLE.'.date_completed'); + return $this; + } +} diff --git a/app/Filter/TaskModificationDateRangeFilter.php b/app/Filter/TaskModificationDateRangeFilter.php new file mode 100644 index 00000000..3daa2b59 --- /dev/null +++ b/app/Filter/TaskModificationDateRangeFilter.php @@ -0,0 +1,38 @@ +<?php + +namespace Kanboard\Filter; + +use Kanboard\Core\Filter\FilterInterface; +use Kanboard\Model\TaskModel; + +/** + * Filter tasks by modification date + * + * @package filter + * @author Kamil Ściana + */ +class TaskModificationDateRangeFilter extends BaseDateRangeFilter implements FilterInterface +{ + /** + * Get search attribute + * + * @access public + * @return string[] + */ + public function getAttributes() + { + return array('updatedRange', 'modifiedRange'); + } + + /** + * Apply filter + * + * @access public + * @return FilterInterface + */ + public function apply() + { + $this->applyDateFilter(TaskModel::TABLE.'.date_modification'); + return $this; + } +} |