mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 23:02:42 +01:00
[conduit: query owners packages by repository]
Summary: There wasn't an easy way to see all the packages that cover a particular directory. This adds the option This is useful to see what's covered within a repo. Test Plan: * Queried with a valid repository and path - got the results as before. * Queried with a repository and no path - got an error as before. * Queried with a repository and an asterix as the path - got all the packages within the repository. Revert Plan: sure Other Notes: Reviewers: epriestley, edward Reviewed By: epriestley CC: aran, Korvin Maniphest Tasks: T3016 Differential Revision: https://secure.phabricator.com/D5763
This commit is contained in:
parent
3bfad75764
commit
9ccb3068f8
2 changed files with 20 additions and 4 deletions
|
@ -74,9 +74,12 @@ final class ConduitAPI_owners_query_Method
|
|||
->setErrorDescription(
|
||||
'Repository callsign '.$repo_callsign.' not recognized');
|
||||
}
|
||||
|
||||
return PhabricatorOwnersPackage::loadOwningPackages(
|
||||
$repository, $path);
|
||||
if ($path == null) {
|
||||
return PhabricatorOwnersPackage::loadPackagesForRepository($repository);
|
||||
} else {
|
||||
return PhabricatorOwnersPackage::loadOwningPackages(
|
||||
$repository, $path);
|
||||
}
|
||||
}
|
||||
|
||||
public static function buildPackageInformationDictionaries($packages) {
|
||||
|
@ -116,7 +119,7 @@ final class ConduitAPI_owners_query_Method
|
|||
|
||||
$repo = $request->getValue('repositoryCallsign');
|
||||
$path = $request->getValue('path');
|
||||
$is_path_query = ($repo && $path) ? 1 : 0;
|
||||
$is_path_query = $repo ? 1 : 0;
|
||||
|
||||
if ($is_owner_query + $is_path_query + $is_affiliated_query === 0) {
|
||||
// if no search terms are provided, return everything
|
||||
|
|
|
@ -182,6 +182,19 @@ final class PhabricatorOwnersPackage extends PhabricatorOwnersDAO
|
|||
return $packages;
|
||||
}
|
||||
|
||||
public static function loadPackagesForRepository($repository) {
|
||||
$package = new PhabricatorOwnersPackage();
|
||||
$ids = ipull(
|
||||
queryfx_all(
|
||||
$package->establishConnection('r'),
|
||||
'SELECT DISTINCT packageID FROM %T WHERE repositoryPHID = %s',
|
||||
id(new PhabricatorOwnersPath())->getTableName(),
|
||||
$repository->getPHID()),
|
||||
'packageID');
|
||||
|
||||
return $package->loadAllWhere('id in (%Ld)', $ids);
|
||||
}
|
||||
|
||||
public static function findLongestPathsPerPackage(array $rows, array $paths) {
|
||||
$ids = array();
|
||||
|
||||
|
|
Loading…
Reference in a new issue