Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14858185
D18785.id45095.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
D18785.id45095.diff
View Options
diff --git a/src/applications/legalpad/query/LegalpadDocumentQuery.php b/src/applications/legalpad/query/LegalpadDocumentQuery.php
--- a/src/applications/legalpad/query/LegalpadDocumentQuery.php
+++ b/src/applications/legalpad/query/LegalpadDocumentQuery.php
@@ -77,23 +77,12 @@
return $this;
}
- protected function loadPage() {
- $table = new LegalpadDocument();
- $conn_r = $table->establishConnection('r');
-
- $data = queryfx_all(
- $conn_r,
- 'SELECT d.* FROM %T d %Q %Q %Q %Q %Q',
- $table->getTableName(),
- $this->buildJoinClause($conn_r),
- $this->buildWhereClause($conn_r),
- $this->buildGroupClause($conn_r),
- $this->buildOrderClause($conn_r),
- $this->buildLimitClause($conn_r));
-
- $documents = $table->loadAllFromArray($data);
+ public function newResultObject() {
+ return new LegalpadDocument();
+ }
- return $documents;
+ protected function loadPage() {
+ return $this->loadStandardPage($this->newResultObject());
}
protected function willFilterPage(array $documents) {
@@ -134,12 +123,12 @@
return $documents;
}
- protected function buildJoinClause(AphrontDatabaseConnection $conn_r) {
- $joins = array();
+ protected function buildJoinClauseParts(AphrontDatabaseConnection $conn) {
+ $joins = parent::buildJoinClauseParts($conn);
if ($this->contributorPHIDs !== null) {
$joins[] = qsprintf(
- $conn_r,
+ $conn,
'JOIN edge contributor ON contributor.src = d.phid
AND contributor.type = %d',
PhabricatorObjectHasContributorEdgeType::EDGECONST);
@@ -147,79 +136,81 @@
if ($this->signerPHIDs !== null) {
$joins[] = qsprintf(
- $conn_r,
+ $conn,
'JOIN %T signer ON signer.documentPHID = d.phid
AND signer.signerPHID IN (%Ls)',
id(new LegalpadDocumentSignature())->getTableName(),
$this->signerPHIDs);
}
- return implode(' ', $joins);
+ return $joins;
}
- protected function buildGroupClause(AphrontDatabaseConnection $conn_r) {
- if ($this->contributorPHIDs || $this->signerPHIDs) {
- return 'GROUP BY d.id';
- } else {
- return '';
+ protected function shouldGroupQueryResultRows() {
+ if ($this->contributorPHIDs) {
+ return true;
}
+
+ if ($this->signerPHIDs) {
+ return true;
+ }
+
+ return parent::shouldGroupQueryResultRows();
}
- protected function buildWhereClause(AphrontDatabaseConnection $conn_r) {
- $where = array();
+ protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) {
+ $where = parent::buildWhereClauseParts($conn);
if ($this->ids !== null) {
$where[] = qsprintf(
- $conn_r,
+ $conn,
'd.id IN (%Ld)',
$this->ids);
}
if ($this->phids !== null) {
$where[] = qsprintf(
- $conn_r,
+ $conn,
'd.phid IN (%Ls)',
$this->phids);
}
if ($this->creatorPHIDs !== null) {
$where[] = qsprintf(
- $conn_r,
+ $conn,
'd.creatorPHID IN (%Ls)',
$this->creatorPHIDs);
}
if ($this->dateCreatedAfter !== null) {
$where[] = qsprintf(
- $conn_r,
+ $conn,
'd.dateCreated >= %d',
$this->dateCreatedAfter);
}
if ($this->dateCreatedBefore !== null) {
$where[] = qsprintf(
- $conn_r,
+ $conn,
'd.dateCreated <= %d',
$this->dateCreatedBefore);
}
if ($this->contributorPHIDs !== null) {
$where[] = qsprintf(
- $conn_r,
+ $conn,
'contributor.dst IN (%Ls)',
$this->contributorPHIDs);
}
if ($this->signatureRequired !== null) {
$where[] = qsprintf(
- $conn_r,
+ $conn,
'd.requireSignature = %d',
$this->signatureRequired);
}
- $where[] = $this->buildPagingClause($conn_r);
-
- return $this->formatWhereClause($where);
+ return $where;
}
private function loadDocumentBodies(array $documents) {
@@ -275,4 +266,8 @@
return 'PhabricatorLegalpadApplication';
}
+ protected function getPrimaryTableAlias() {
+ return 'd';
+ }
+
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Feb 6, 9:53 PM (15 h, 35 s)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7098003
Default Alt Text
D18785.id45095.diff (4 KB)
Attached To
Mode
D18785: Lightly modernize LegalpadDocumentQuery
Attached
Detach File
Event Timeline
Log In to Comment