1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-27 09:12:41 +01:00

Add date filtering to Maniphest "pro" search

Summary: Adds date created filtering. There's a task for this somewhere that I can't immediately find.

Test Plan: Filtered tasks.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D6952
This commit is contained in:
epriestley 2013-09-12 13:03:39 -07:00
parent bdef58216e
commit 1c43fceffb
2 changed files with 50 additions and 0 deletions

View file

@ -20,6 +20,8 @@ final class ManiphestTaskQuery
private $anyProjectPHIDs = array(); private $anyProjectPHIDs = array();
private $anyUserProjectPHIDs = array(); private $anyUserProjectPHIDs = array();
private $includeNoProject = null; private $includeNoProject = null;
private $dateCreatedAfter;
private $dateCreatedBefore;
private $fullTextSearch = ''; private $fullTextSearch = '';
@ -183,6 +185,16 @@ final class ManiphestTaskQuery
return $this; return $this;
} }
public function withDateCreatedBefore($date_created_before) {
$this->dateCreatedBefore = $date_created_before;
return $this;
}
public function withDateCreatedAfter($date_created_after) {
$this->dateCreatedAfter = $date_created_after;
return $this;
}
public function loadPage() { public function loadPage() {
// TODO: (T603) It is possible for a user to find the PHID of a project // TODO: (T603) It is possible for a user to find the PHID of a project
@ -220,6 +232,22 @@ final class ManiphestTaskQuery
$where[] = $this->buildXProjectWhereClause($conn); $where[] = $this->buildXProjectWhereClause($conn);
$where[] = $this->buildFullTextWhereClause($conn); $where[] = $this->buildFullTextWhereClause($conn);
// TODO: Add a key for this the next time we hit this table.
if ($this->dateCreatedAfter) {
$where[] = qsprintf(
$conn,
'dateCreated >= %d',
$this->dateCreatedAfter);
}
if ($this->dateCreatedBefore) {
$where[] = qsprintf(
$conn,
'dateCreated <= %d',
$this->dateCreatedBefore);
}
$where = $this->formatWhereClause($where); $where = $this->formatWhereClause($where);
$join = array(); $join = array();

View file

@ -53,6 +53,9 @@ final class ManiphestTaskSearchEngine
'userProjectPHIDs', 'userProjectPHIDs',
$this->readUsersFromRequest($request, 'userProjects')); $this->readUsersFromRequest($request, 'userProjects'));
$saved->setParameter('createdStart', $request->getStr('createdStart'));
$saved->setParameter('createdEnd', $request->getStr('createdEnd'));
return $saved; return $saved;
} }
@ -127,6 +130,17 @@ final class ManiphestTaskSearchEngine
$query->withAnyUserProjects($user_project_phids); $query->withAnyUserProjects($user_project_phids);
} }
$start = $this->parseDateTime($saved->getParameter('createdStart'));
$end = $this->parseDateTime($saved->getParameter('createdEnd'));
if ($start) {
$query->withDateCreatedAfter($start);
}
if ($end) {
$query->withDateCreatedBefore($end);
}
return $query; return $query;
} }
@ -273,6 +287,14 @@ final class ManiphestTaskSearchEngine
->setName('ids') ->setName('ids')
->setLabel(pht('Task IDs')) ->setLabel(pht('Task IDs'))
->setValue(implode(', ', $ids))); ->setValue(implode(', ', $ids)));
$this->buildDateRange(
$form,
$saved,
'createdStart',
pht('Created After'),
'createdEnd',
pht('Created Before'));
} }
protected function getURI($path) { protected function getURI($path) {