1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-23 14:00:56 +01:00

Add date range filtering for activity, push, and pull logs

Summary: Ref T13049. This is just a general nice-to-have so you don't have to export a 300MB file if you want to check the last month of data or whatever.

Test Plan: Applied filters to all three logs, got appropriate date-range result sets.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13049

Differential Revision: https://secure.phabricator.com/D18970
This commit is contained in:
epriestley 2018-01-30 11:47:55 -08:00
parent 0d5379ee17
commit 75bc86589f
7 changed files with 105 additions and 0 deletions

View file

@ -26,6 +26,12 @@ final class DiffusionPullLogSearchEngine
$query->withPullerPHIDs($map['pullerPHIDs']);
}
if ($map['createdStart'] || $map['createdEnd']) {
$query->withEpochBetween(
$map['createdStart'],
$map['createdEnd']);
}
return $query;
}
@ -44,6 +50,12 @@ final class DiffusionPullLogSearchEngine
->setLabel(pht('Pullers'))
->setDescription(
pht('Search for pull logs by specific users.')),
id(new PhabricatorSearchDateField())
->setLabel(pht('Created After'))
->setKey('createdStart'),
id(new PhabricatorSearchDateField())
->setLabel(pht('Created Before'))
->setKey('createdEnd'),
);
}

View file

@ -9,6 +9,8 @@ final class PhabricatorPeopleLogQuery
private $sessionKeys;
private $actions;
private $remoteAddressPrefix;
private $dateCreatedMin;
private $dateCreatedMax;
public function withActorPHIDs(array $actor_phids) {
$this->actorPHIDs = $actor_phids;
@ -40,6 +42,12 @@ final class PhabricatorPeopleLogQuery
return $this;
}
public function withDateCreatedBetween($min, $max) {
$this->dateCreatedMin = $min;
$this->dateCreatedMax = $max;
return $this;
}
public function newResultObject() {
return new PhabricatorUserLog();
}
@ -94,6 +102,20 @@ final class PhabricatorPeopleLogQuery
$this->remoteAddressPrefix);
}
if ($this->dateCreatedMin !== null) {
$where[] = qsprintf(
$conn,
'dateCreated >= %d',
$this->dateCreatedMin);
}
if ($this->dateCreatedMax !== null) {
$where[] = qsprintf(
$conn,
'dateCreated <= %d',
$this->dateCreatedMax);
}
return $where;
}

View file

@ -54,6 +54,12 @@ final class PhabricatorPeopleLogSearchEngine
$query->withSessionKeys($map['sessions']);
}
if ($map['createdStart'] || $map['createdEnd']) {
$query->withDateCreatedBetween(
$map['createdStart'],
$map['createdEnd']);
}
return $query;
}
@ -82,6 +88,12 @@ final class PhabricatorPeopleLogSearchEngine
->setKey('sessions')
->setLabel(pht('Sessions'))
->setDescription(pht('Search for activity in particular sessions.')),
id(new PhabricatorSearchDateField())
->setLabel(pht('Created After'))
->setKey('createdStart'),
id(new PhabricatorSearchDateField())
->setLabel(pht('Created Before'))
->setKey('createdEnd'),
);
}

View file

@ -7,6 +7,8 @@ final class PhabricatorRepositoryPullEventQuery
private $phids;
private $repositoryPHIDs;
private $pullerPHIDs;
private $epochMin;
private $epochMax;
public function withIDs(array $ids) {
$this->ids = $ids;
@ -28,6 +30,12 @@ final class PhabricatorRepositoryPullEventQuery
return $this;
}
public function withEpochBetween($min, $max) {
$this->epochMin = $min;
$this->epochMax = $max;
return $this;
}
public function newResultObject() {
return new PhabricatorRepositoryPullEvent();
}
@ -103,6 +111,20 @@ final class PhabricatorRepositoryPullEventQuery
$this->pullerPHIDs);
}
if ($this->epochMin !== null) {
$where[] = qsprintf(
$conn,
'epoch >= %d',
$this->epochMin);
}
if ($this->epochMax !== null) {
$where[] = qsprintf(
$conn,
'epoch <= %d',
$this->epochMax);
}
return $where;
}

View file

@ -10,6 +10,8 @@ final class PhabricatorRepositoryPushLogQuery
private $refTypes;
private $newRefs;
private $pushEventPHIDs;
private $epochMin;
private $epochMax;
public function withIDs(array $ids) {
$this->ids = $ids;
@ -46,6 +48,12 @@ final class PhabricatorRepositoryPushLogQuery
return $this;
}
public function withEpochBetween($min, $max) {
$this->epochMin = $min;
$this->epochMax = $max;
return $this;
}
public function newResultObject() {
return new PhabricatorRepositoryPushLog();
}
@ -127,6 +135,20 @@ final class PhabricatorRepositoryPushLogQuery
$this->newRefs);
}
if ($this->epochMin !== null) {
$where[] = qsprintf(
$conn,
'epoch >= %d',
$this->epochMin);
}
if ($this->epochMax !== null) {
$where[] = qsprintf(
$conn,
'epoch <= %d',
$this->epochMax);
}
return $where;
}

View file

@ -26,6 +26,12 @@ final class PhabricatorRepositoryPushLogSearchEngine
$query->withPusherPHIDs($map['pusherPHIDs']);
}
if ($map['createdStart'] || $map['createdEnd']) {
$query->withEpochBetween(
$map['createdStart'],
$map['createdEnd']);
}
return $query;
}
@ -44,6 +50,12 @@ final class PhabricatorRepositoryPushLogSearchEngine
->setLabel(pht('Pushers'))
->setDescription(
pht('Search for pull logs by specific users.')),
id(new PhabricatorSearchDateField())
->setLabel(pht('Created After'))
->setKey('createdStart'),
id(new PhabricatorSearchDateField())
->setLabel(pht('Created Before'))
->setKey('createdEnd'),
);
}

View file

@ -124,6 +124,9 @@ final class PhabricatorRepositoryPushLog
'key_pusher' => array(
'columns' => array('pusherPHID'),
),
'key_epoch' => array(
'columns' => array('epoch'),
),
),
) + parent::getConfiguration();
}