@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add more constraints to "harbormaster.target.search"

Summary: Ref T13607. Add some time-oriented constraints to this API method to support compiling build statistics.

Test Plan:
- Called "harbormaster.target.search" with all new constraints.
- Viewed documentation in API console.

Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam

Maniphest Tasks: T13607

Differential Revision: https://secure.phabricator.com/D21559

+147
+80
src/applications/harbormaster/query/HarbormasterBuildTargetQuery.php
··· 7 7 private $phids; 8 8 private $buildPHIDs; 9 9 private $buildGenerations; 10 + private $dateCreatedMin; 11 + private $dateCreatedMax; 12 + private $dateStartedMin; 13 + private $dateStartedMax; 14 + private $dateCompletedMin; 15 + private $dateCompletedMax; 16 + private $statuses; 17 + 10 18 private $needBuildSteps; 11 19 12 20 public function withIDs(array $ids) { ··· 29 37 return $this; 30 38 } 31 39 40 + public function withDateCreatedBetween($min, $max) { 41 + $this->dateCreatedMin = $min; 42 + $this->dateCreatedMax = $max; 43 + return $this; 44 + } 45 + 46 + public function withDateStartedBetween($min, $max) { 47 + $this->dateStartedMin = $min; 48 + $this->dateStartedMax = $max; 49 + return $this; 50 + } 51 + 52 + public function withDateCompletedBetween($min, $max) { 53 + $this->dateCompletedMin = $min; 54 + $this->dateCompletedMax = $max; 55 + return $this; 56 + } 57 + 58 + public function withTargetStatuses(array $statuses) { 59 + $this->statuses = $statuses; 60 + return $this; 61 + } 62 + 32 63 public function needBuildSteps($need_build_steps) { 33 64 $this->needBuildSteps = $need_build_steps; 34 65 return $this; ··· 71 102 $conn, 72 103 'buildGeneration in (%Ld)', 73 104 $this->buildGenerations); 105 + } 106 + 107 + if ($this->dateCreatedMin !== null) { 108 + $where[] = qsprintf( 109 + $conn, 110 + 'dateCreated >= %d', 111 + $this->dateCreatedMin); 112 + } 113 + 114 + if ($this->dateCreatedMax !== null) { 115 + $where[] = qsprintf( 116 + $conn, 117 + 'dateCreated <= %d', 118 + $this->dateCreatedMax); 119 + } 120 + 121 + if ($this->dateStartedMin !== null) { 122 + $where[] = qsprintf( 123 + $conn, 124 + 'dateStarted >= %d', 125 + $this->dateStartedMin); 126 + } 127 + 128 + if ($this->dateStartedMax !== null) { 129 + $where[] = qsprintf( 130 + $conn, 131 + 'dateStarted <= %d', 132 + $this->dateStartedMax); 133 + } 134 + 135 + if ($this->dateCompletedMin !== null) { 136 + $where[] = qsprintf( 137 + $conn, 138 + 'dateCompleted >= %d', 139 + $this->dateCompletedMin); 140 + } 141 + 142 + if ($this->dateCompletedMax !== null) { 143 + $where[] = qsprintf( 144 + $conn, 145 + 'dateCompleted <= %d', 146 + $this->dateCompletedMax); 147 + } 148 + 149 + if ($this->statuses !== null) { 150 + $where[] = qsprintf( 151 + $conn, 152 + 'targetStatus IN (%Ls)', 153 + $this->statuses); 74 154 } 75 155 76 156 return $where;
+58
src/applications/harbormaster/query/HarbormasterBuildTargetSearchEngine.php
··· 24 24 ->setDescription( 25 25 pht('Search for targets of a given build.')) 26 26 ->setDatasource(new HarbormasterBuildPlanDatasource()), 27 + id(new PhabricatorSearchDateField()) 28 + ->setLabel(pht('Created After')) 29 + ->setKey('createdStart') 30 + ->setDescription( 31 + pht('Search for targets created on or after a particular date.')), 32 + id(new PhabricatorSearchDateField()) 33 + ->setLabel(pht('Created Before')) 34 + ->setKey('createdEnd') 35 + ->setDescription( 36 + pht('Search for targets created on or before a particular date.')), 37 + id(new PhabricatorSearchDateField()) 38 + ->setLabel(pht('Started After')) 39 + ->setKey('startedStart') 40 + ->setDescription( 41 + pht('Search for targets started on or after a particular date.')), 42 + id(new PhabricatorSearchDateField()) 43 + ->setLabel(pht('Started Before')) 44 + ->setKey('startedEnd') 45 + ->setDescription( 46 + pht('Search for targets started on or before a particular date.')), 47 + id(new PhabricatorSearchDateField()) 48 + ->setLabel(pht('Completed After')) 49 + ->setKey('completedStart') 50 + ->setDescription( 51 + pht('Search for targets completed on or after a particular date.')), 52 + id(new PhabricatorSearchDateField()) 53 + ->setLabel(pht('Completed Before')) 54 + ->setKey('completedEnd') 55 + ->setDescription( 56 + pht('Search for targets completed on or before a particular date.')), 57 + id(new PhabricatorSearchStringListField()) 58 + ->setLabel(pht('Statuses')) 59 + ->setKey('statuses') 60 + ->setAliases(array('status')) 61 + ->setDescription( 62 + pht('Search for targets with given statuses.')), 27 63 ); 28 64 } 29 65 ··· 32 68 33 69 if ($map['buildPHIDs']) { 34 70 $query->withBuildPHIDs($map['buildPHIDs']); 71 + } 72 + 73 + if ($map['createdStart'] !== null || $map['createdEnd'] !== null) { 74 + $query->withDateCreatedBetween( 75 + $map['createdStart'], 76 + $map['createdEnd']); 77 + } 78 + 79 + if ($map['startedStart'] !== null || $map['startedEnd'] !== null) { 80 + $query->withDateStartedBetween( 81 + $map['startedStart'], 82 + $map['startedEnd']); 83 + } 84 + 85 + if ($map['completedStart'] !== null || $map['completedEnd'] !== null) { 86 + $query->withDateCompletedBetween( 87 + $map['completedStart'], 88 + $map['completedEnd']); 89 + } 90 + 91 + if ($map['statuses']) { 92 + $query->withTargetStatuses($map['statuses']); 35 93 } 36 94 37 95 return $query;
+9
src/applications/harbormaster/storage/build/HarbormasterBuildTarget.php
··· 119 119 'key_build' => array( 120 120 'columns' => array('buildPHID', 'buildStepPHID'), 121 121 ), 122 + 'key_started' => array( 123 + 'columns' => array('dateStarted'), 124 + ), 125 + 'key_completed' => array( 126 + 'columns' => array('dateCompleted'), 127 + ), 128 + 'key_created' => array( 129 + 'columns' => array('dateCreated'), 130 + ), 122 131 ), 123 132 ) + parent::getConfiguration(); 124 133 }