@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.

at recaptime-dev/main 116 lines 2.8 kB view raw
1<?php 2 3/** 4 * @extends PhabricatorCursorPagedPolicyAwareQuery<HarbormasterBuildArtifact> 5 */ 6final class HarbormasterBuildArtifactQuery 7 extends PhabricatorCursorPagedPolicyAwareQuery { 8 9 private $ids; 10 private $buildTargetPHIDs; 11 private $artifactTypes; 12 private $artifactIndexes; 13 private $keyBuildPHID; 14 private $keyBuildGeneration; 15 private $isReleased; 16 17 public function withIDs(array $ids) { 18 $this->ids = $ids; 19 return $this; 20 } 21 22 public function withBuildTargetPHIDs(array $build_target_phids) { 23 $this->buildTargetPHIDs = $build_target_phids; 24 return $this; 25 } 26 27 public function withArtifactTypes(array $artifact_types) { 28 $this->artifactTypes = $artifact_types; 29 return $this; 30 } 31 32 public function withArtifactIndexes(array $artifact_indexes) { 33 $this->artifactIndexes = $artifact_indexes; 34 return $this; 35 } 36 37 public function withIsReleased($released) { 38 $this->isReleased = $released; 39 return $this; 40 } 41 42 public function newResultObject() { 43 return new HarbormasterBuildArtifact(); 44 } 45 46 protected function willFilterPage(array $page) { 47 $build_targets = array(); 48 49 $build_target_phids = array_filter(mpull($page, 'getBuildTargetPHID')); 50 if ($build_target_phids) { 51 $build_targets = id(new HarbormasterBuildTargetQuery()) 52 ->setViewer($this->getViewer()) 53 ->withPHIDs($build_target_phids) 54 ->setParentQuery($this) 55 ->execute(); 56 $build_targets = mpull($build_targets, null, 'getPHID'); 57 } 58 59 foreach ($page as $key => $build_log) { 60 $build_target_phid = $build_log->getBuildTargetPHID(); 61 if (empty($build_targets[$build_target_phid])) { 62 unset($page[$key]); 63 continue; 64 } 65 $build_log->attachBuildTarget($build_targets[$build_target_phid]); 66 } 67 68 return $page; 69 } 70 71 protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { 72 $where = parent::buildWhereClauseParts($conn); 73 74 if ($this->ids !== null) { 75 $where[] = qsprintf( 76 $conn, 77 'id IN (%Ld)', 78 $this->ids); 79 } 80 81 if ($this->buildTargetPHIDs !== null) { 82 $where[] = qsprintf( 83 $conn, 84 'buildTargetPHID IN (%Ls)', 85 $this->buildTargetPHIDs); 86 } 87 88 if ($this->artifactTypes !== null) { 89 $where[] = qsprintf( 90 $conn, 91 'artifactType in (%Ls)', 92 $this->artifactTypes); 93 } 94 95 if ($this->artifactIndexes !== null) { 96 $where[] = qsprintf( 97 $conn, 98 'artifactIndex IN (%Ls)', 99 $this->artifactIndexes); 100 } 101 102 if ($this->isReleased !== null) { 103 $where[] = qsprintf( 104 $conn, 105 'isReleased = %d', 106 (int)$this->isReleased); 107 } 108 109 return $where; 110 } 111 112 public function getQueryApplicationClass() { 113 return PhabricatorHarbormasterApplication::class; 114 } 115 116}