Page MenuHomePhorge

PhabricatorDiagramVersionQuery.php
No OneTemporary

PhabricatorDiagramVersionQuery.php

<?php
final class PhabricatorDiagramVersionQuery
extends PhabricatorCursorPagedPolicyAwareQuery {
protected $diagramIDs;
protected $modifiedAfter;
protected $modifiedBefore;
public function withDiagramIDs(array $diagram_ids) {
$this->diagramIDs = $diagram_ids;
return $this;
}
public function withIDs(array $diagram_ids) {
return $this->withDiagramIDs($diagram_ids);
}
public function withModifiedAfter($datetime) {
$this->modifiedAfter = $datetime;
return $this;
}
public function withModifiedBefore($datetime) {
$this->modifiedBefore = $datetime;
return $this;
}
protected function loadPage() {
$table = new DiagramVersion();
$conn_r = $table->establishConnection('r');
// we return a DiagramVersion object which has a different id
// than the one we mention in the Remarkup code.
// E.g. {DIAG1} may point to the 2nd version of the object.
// Diagram's id is 1, but DiagramVersion's id is 2.
// Because of this we abuse the id in the resultset a little bit
$data = queryfx_all(
$conn_r,
'SELECT *
FROM (
SELECT result.diagramID AS id, /* abuse */
result.diagramID,
result.version,
result.phid,
result.authorPHID,
result.dateCreated,
result.dateModified,
result.byteSize,
result.data,
result.viewPolicy,
result.editPolicy
FROM (
SELECT data.*
FROM %T data
INNER JOIN (
SELECT MAX(id) AS id,
diagramid
FROM %T
GROUP BY diagramid HAVING MAX(id)
) filter
ON data.id = filter.id
) result
) r %Q %Q %Q',
$table->getTableName(),
$table->getTableName(),
$this->buildWhereClause($conn_r),
$this->buildOrderClause($conn_r),
$this->buildLimitClause($conn_r));
return $table->loadAllFromArray($data);
}
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) {
$where = array();
$where[] = $this->buildPagingClause($conn_r);
if ($this->diagramIDs !== null) {
$where[] = qsprintf(
$conn_r,
'diagramID IN (%Ld)',
$this->diagramIDs);
}
if ($this->modifiedAfter !== null) {
$where[] = qsprintf(
$conn_r,
'dateModified >= %d',
$this->modifiedAfter);
}
if ($this->modifiedBefore !== null) {
$where[] = qsprintf(
$conn_r,
'dateModified <= %d',
$this->modifiedBefore);
}
return $this->formatWhereClause($conn_r, $where);
}
public function getQueryApplicationClass() {
return DiagramApplication::class;
}
}

File Metadata

Mime Type
text/x-php
Expires
Sun, Jan 19, 20:18 (1 w, 5 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1128382
Default Alt Text
PhabricatorDiagramVersionQuery.php (2 KB)

Event Timeline