1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-11 07:11:04 +01:00

Convert simple query subclasses to use internal cursors

Summary:
Depends on D20291. Ref T13259. Move all the simple cases (where paging depends only on the partial object and does not depend on keys) to a simple wrapper.

This leaves a smaller set of more complex cases where we care about external data or which keys were requested that I'll convert in followups.

Test Plan: Poked at things, but a lot of stuff is still broken until everything is converted.

Reviewers: amckinley

Reviewed By: amckinley

Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam

Maniphest Tasks: T13259

Differential Revision: https://secure.phabricator.com/D20292
This commit is contained in:
epriestley 2019-03-18 11:44:54 -07:00
parent 1b0ef43910
commit d4847c3eeb
20 changed files with 61 additions and 84 deletions

View file

@ -122,11 +122,10 @@ final class AlmanacDeviceQuery
);
}
protected function getPagingValueMap($cursor, array $keys) {
$device = $this->loadCursorObject($cursor);
protected function newPagingMapFromPartialObject($object) {
return array(
'id' => $device->getID(),
'name' => $device->getName(),
'id' => (int)$object->getID(),
'name' => $object->getName(),
);
}

View file

@ -79,11 +79,10 @@ final class AlmanacNamespaceQuery
);
}
protected function getPagingValueMap($cursor, array $keys) {
$namespace = $this->loadCursorObject($cursor);
protected function newPagingMapFromPartialObject($object) {
return array(
'id' => $namespace->getID(),
'name' => $namespace->getName(),
'id' => (int)$object->getID(),
'name' => $object->getName(),
);
}

View file

@ -206,11 +206,10 @@ final class AlmanacServiceQuery
);
}
protected function getPagingValueMap($cursor, array $keys) {
$service = $this->loadCursorObject($cursor);
protected function newPagingMapFromPartialObject($object) {
return array(
'id' => $service->getID(),
'name' => $service->getName(),
'id' => (int)$object->getID(),
'name' => $object->getName(),
);
}

View file

@ -108,11 +108,11 @@ final class PhabricatorBadgesQuery
) + parent::getOrderableColumns();
}
protected function getPagingValueMap($cursor, array $keys) {
$badge = $this->loadCursorObject($cursor);
protected function newPagingMapFromPartialObject($object) {
return array(
'quality' => $badge->getQuality(),
'id' => $badge->getID(),
'id' => (int)$object->getID(),
'quality' => $object->getQuality(),
);
}

View file

@ -140,11 +140,10 @@ final class PhabricatorCalendarEventQuery
) + parent::getOrderableColumns();
}
protected function getPagingValueMap($cursor, array $keys) {
$event = $this->loadCursorObject($cursor);
protected function newPagingMapFromPartialObject($object) {
return array(
'start' => $event->getStartDateTimeEpoch(),
'id' => $event->getID(),
'id' => (int)$object->getID(),
'start' => (int)$object->getStartDateTimeEpoch(),
);
}

View file

@ -97,11 +97,10 @@ final class PhabricatorCountdownQuery
) + parent::getOrderableColumns();
}
protected function getPagingValueMap($cursor, array $keys) {
$countdown = $this->loadCursorObject($cursor);
protected function newPagingMapFromPartialObject($object) {
return array(
'epoch' => $countdown->getEpoch(),
'id' => $countdown->getID(),
'id' => (int)$object->getID(),
'epoch' => (int)$object->getEpoch(),
);
}

View file

@ -800,11 +800,10 @@ final class DifferentialRevisionQuery
) + parent::getOrderableColumns();
}
protected function getPagingValueMap($cursor, array $keys) {
$revision = $this->loadCursorObject($cursor);
protected function newPagingMapFromPartialObject($object) {
return array(
'id' => $revision->getID(),
'updated' => $revision->getDateModified(),
'id' => (int)$object->getID(),
'updated' => (int)$object->getDateModified(),
);
}

View file

@ -924,11 +924,10 @@ final class DiffusionCommitQuery
);
}
protected function getPagingValueMap($cursor, array $keys) {
$commit = $this->loadCursorObject($cursor);
protected function newPagingMapFromPartialObject($object) {
return array(
'id' => $commit->getID(),
'epoch' => $commit->getEpoch(),
'id' => (int)$object->getID(),
'epoch' => (int)$object->getEpoch(),
);
}

View file

@ -181,11 +181,10 @@ final class DivinerBookQuery extends PhabricatorCursorPagedPolicyAwareQuery {
);
}
protected function getPagingValueMap($cursor, array $keys) {
$book = $this->loadCursorObject($cursor);
protected function newPagingMapFromPartialObject($object) {
return array(
'name' => $book->getName(),
'id' => (int)$object->getID(),
'name' => $object->getName(),
);
}

View file

@ -133,11 +133,10 @@ final class HarbormasterBuildPlanQuery
);
}
protected function getPagingValueMap($cursor, array $keys) {
$plan = $this->loadCursorObject($cursor);
protected function newPagingMapFromPartialObject($object) {
return array(
'id' => $plan->getID(),
'name' => $plan->getName(),
'id' => (int)$object->getID(),
'name' => $object->getName(),
);
}

View file

@ -249,11 +249,10 @@ final class PhabricatorMacroQuery
);
}
protected function getPagingValueMap($cursor, array $keys) {
$macro = $this->loadCursorObject($cursor);
protected function newPagingMapFromPartialObject($object) {
return array(
'id' => $macro->getID(),
'name' => $macro->getName(),
'id' => (int)$object->getID(),
'name' => $object->getName(),
);
}

View file

@ -267,11 +267,10 @@ final class PhabricatorOwnersPackageQuery
);
}
protected function getPagingValueMap($cursor, array $keys) {
$package = $this->loadCursorObject($cursor);
protected function newPagingMapFromPartialObject($object) {
return array(
'id' => $package->getID(),
'name' => $package->getName(),
'id' => (int)$object->getID(),
'name' => $object->getName(),
);
}

View file

@ -379,11 +379,10 @@ final class PhabricatorPeopleQuery
);
}
protected function getPagingValueMap($cursor, array $keys) {
$user = $this->loadCursorObject($cursor);
protected function newPagingMapFromPartialObject($object) {
return array(
'id' => $user->getID(),
'username' => $user->getUsername(),
'id' => (int)$object->getID(),
'username' => $object->getUsername(),
);
}

View file

@ -171,15 +171,11 @@ final class PhamePostQuery extends PhabricatorCursorPagedPolicyAwareQuery {
);
}
protected function getPagingValueMap($cursor, array $keys) {
$post = $this->loadCursorObject($cursor);
$map = array(
'datePublished' => $post->getDatePublished(),
'id' => $post->getID(),
protected function newPagingMapFromPartialObject($object) {
return array(
'id' => (int)$object->getID(),
'datePublished' => (int)$object->getDatePublished(),
);
return $map;
}
public function getQueryApplicationClass() {

View file

@ -81,9 +81,9 @@ final class PhluxVariableQuery
);
}
protected function getPagingValueMap($cursor, array $keys) {
$object = $this->loadCursorObject($cursor);
protected function newPagingMapFromPartialObject($object) {
return array(
'id' => (int)$object->getID(),
'key' => $object->getVariableKey(),
);
}

View file

@ -133,12 +133,11 @@ final class PhrequentUserTimeQuery
);
}
protected function getPagingValueMap($cursor, array $keys) {
$usertime = $this->loadCursorObject($cursor);
protected function newPagingMapFromPartialObject($object) {
return array(
'id' => $usertime->getID(),
'start' => $usertime->getDateStarted(),
'end' => $usertime->getDateEnded(),
'id' => (int)$object->getID(),
'start' => (int)$object->getDateStarted(),
'end' => (int)$object->getDateEnded(),
);
}

View file

@ -50,13 +50,6 @@ final class PhabricatorPhurlURLQuery
return $this;
}
protected function getPagingValueMap($cursor, array $keys) {
$url = $this->loadCursorObject($cursor);
return array(
'id' => $url->getID(),
);
}
protected function loadPage() {
return $this->loadStandardPage($this->newResultObject());
}

View file

@ -201,12 +201,11 @@ final class PhabricatorProjectQuery
);
}
protected function getPagingValueMap($cursor, array $keys) {
$project = $this->loadCursorObject($cursor);
protected function newPagingMapFromPartialObject($object) {
return array(
'id' => $project->getID(),
'name' => $project->getName(),
'status' => $project->getStatus(),
'id' => (int)$object->getID(),
'name' => $object->getName(),
'status' => $object->getStatus(),
);
}

View file

@ -130,12 +130,10 @@ final class ReleephProductQuery
);
}
protected function getPagingValueMap($cursor, array $keys) {
$product = $this->loadCursorObject($cursor);
protected function newPagingMapFromPartialObject($object) {
return array(
'id' => $product->getID(),
'name' => $product->getName(),
'id' => (int)$object->getID(),
'name' => $object->getName(),
);
}

View file

@ -62,6 +62,10 @@ abstract class PhabricatorCursorPagedPolicyAwareQuery
$object = $cursor->getObject();
return $this->newPagingMapFromPartialObject($object);
}
protected function newPagingMapFromPartialObject($object) {
return array(
'id' => (int)$object->getID(),
);