/** * @task exec */ public function execute() { if ($this->name && $this->namePrefix) { throw new Exception("You can not set both a name and a name prefix!"); } else { if (!$this->name && !$this->namePrefix) { throw new Exception("You must set a name or a name prefix!"); } } $symbol = new PhabricatorRepositorySymbol(); $conn_r = $symbol->establishConnection('r'); $data = queryfx_all($conn_r, 'SELECT * FROM %T %Q %Q %Q', $symbol->getTableName(), $this->buildWhereClause($conn_r), $this->buildOrderClause($conn_r), $this->buildLimitClause($conn_r)); $symbols = $symbol->loadAllFromArray($data); if ($symbols) { if ($this->needPaths) { $this->loadPaths($symbols); } if ($this->needArcanistProjects || $this->needRepositories) { $this->loadArcanistProjects($symbols); } if ($this->needRepositories) { $this->loadRepositories($symbols); } } return $symbols; }
/** * @task exec */ public function execute() { if ($this->name && $this->namePrefix) { throw new Exception("You can not set both a name and a name prefix!"); } else { if (!$this->name && !$this->namePrefix) { throw new Exception("You must set a name or a name prefix!"); } } $symbol = new PhabricatorRepositorySymbol(); $conn_r = $symbol->establishConnection('r'); $where = array(); if ($this->name) { $where[] = qsprintf($conn_r, 'symbolName = %s', $this->name); } if ($this->namePrefix) { $where[] = qsprintf($conn_r, 'symbolName LIKE %>', $this->namePrefix); } if ($this->projectIDs) { $where[] = qsprintf($conn_r, 'arcanistProjectID IN (%Ld)', $this->projectIDs); } $where = 'WHERE (' . implode(') AND (', $where) . ')'; $data = queryfx_all($conn_r, 'SELECT * FROM %T %Q', $symbol->getTableName(), $where); // Our ability to match up symbol types and languages probably isn't all // that great, so use them as hints for ranking rather than hard // requirements. TODO: Is this really the right choice? foreach ($data as $key => $row) { $score = 0; if ($this->language && $row['symbolLanguage'] == $this->language) { $score += 2; } if ($this->type && $row['symbolType'] == $this->type) { $score += 1; } $data[$key]['score'] = $score; $data[$key]['id'] = $key; } $data = isort($data, 'score'); $data = array_reverse($data); $data = array_slice($data, 0, $this->limit); $symbols = $symbol->loadAllFromArray($data); if ($symbols) { if ($this->needPaths) { $this->loadPaths($symbols); } if ($this->needArcanistProjects || $this->needRepositories) { $this->loadArcanistProjects($symbols); } if ($this->needRepositories) { $this->loadRepositories($symbols); } } return $symbols; }