mirror of
https://we.phorge.it/source/phorge.git
synced 2025-03-03 07:59:15 +01:00
Summary: Depends on D19785. Ref T13217. This converts many of the most common clause construction pathways to the new %Q / %LQ / %LO / %LA / %LJ semantics. Test Plan: Browsed around a bunch, saw fewer warnings and no obvious behavioral errors. The transformations here are generally mechanical (although I did them by hand). Reviewers: amckinley Reviewed By: amckinley Subscribers: hach-que Maniphest Tasks: T13217 Differential Revision: https://secure.phabricator.com/D19789
84 lines
1.9 KiB
PHP
84 lines
1.9 KiB
PHP
<?php
|
|
|
|
final class PhabricatorChatLogQuery
|
|
extends PhabricatorCursorPagedPolicyAwareQuery {
|
|
|
|
private $channelIDs;
|
|
private $maximumEpoch;
|
|
|
|
public function withChannelIDs(array $channel_ids) {
|
|
$this->channelIDs = $channel_ids;
|
|
return $this;
|
|
}
|
|
|
|
public function withMaximumEpoch($epoch) {
|
|
$this->maximumEpoch = $epoch;
|
|
return $this;
|
|
}
|
|
|
|
protected function loadPage() {
|
|
$table = new PhabricatorChatLogEvent();
|
|
$conn_r = $table->establishConnection('r');
|
|
|
|
$data = queryfx_all(
|
|
$conn_r,
|
|
'SELECT * FROM %T e %Q %Q %Q',
|
|
$table->getTableName(),
|
|
$this->buildWhereClause($conn_r),
|
|
$this->buildOrderClause($conn_r),
|
|
$this->buildLimitClause($conn_r));
|
|
|
|
$logs = $table->loadAllFromArray($data);
|
|
|
|
return $logs;
|
|
}
|
|
|
|
protected function willFilterPage(array $events) {
|
|
$channel_ids = mpull($events, 'getChannelID', 'getChannelID');
|
|
|
|
$channels = id(new PhabricatorChatLogChannelQuery())
|
|
->setViewer($this->getViewer())
|
|
->withIDs($channel_ids)
|
|
->execute();
|
|
$channels = mpull($channels, null, 'getID');
|
|
|
|
foreach ($events as $key => $event) {
|
|
$channel = idx($channels, $event->getChannelID());
|
|
if (!$channel) {
|
|
unset($events[$key]);
|
|
continue;
|
|
}
|
|
|
|
$event->attachChannel($channel);
|
|
}
|
|
|
|
return $events;
|
|
}
|
|
|
|
protected function buildWhereClause(AphrontDatabaseConnection $conn) {
|
|
$where = array();
|
|
|
|
$where[] = $this->buildPagingClause($conn);
|
|
|
|
if ($this->maximumEpoch !== null) {
|
|
$where[] = qsprintf(
|
|
$conn,
|
|
'epoch <= %d',
|
|
$this->maximumEpoch);
|
|
}
|
|
|
|
if ($this->channelIDs !== null) {
|
|
$where[] = qsprintf(
|
|
$conn,
|
|
'channelID IN (%Ld)',
|
|
$this->channelIDs);
|
|
}
|
|
|
|
return $this->formatWhereClause($conn, $where);
|
|
}
|
|
|
|
public function getQueryApplicationClass() {
|
|
return 'PhabricatorChatLogApplication';
|
|
}
|
|
|
|
}
|