mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-02 02:40:58 +01:00
Moving code off channel
Summary: Deleted code which used channel. Created PhabricatorChatLogChannelQuery.php Test Plan: By manually checking in the chatlog application. Reviewers: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D5010
This commit is contained in:
parent
53f527f71f
commit
3b2aed16c9
9 changed files with 77 additions and 38 deletions
|
@ -754,6 +754,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorChatLogChannel' => 'applications/chatlog/storage/PhabricatorChatLogChannel.php',
|
||||
'PhabricatorChatLogChannelListController' => 'applications/chatlog/controller/PhabricatorChatLogChannelListController.php',
|
||||
'PhabricatorChatLogChannelLogController' => 'applications/chatlog/controller/PhabricatorChatLogChannelLogController.php',
|
||||
'PhabricatorChatLogChannelQuery' => 'applications/chatlog/PhabricatorChatLogChannelQuery.php',
|
||||
'PhabricatorChatLogConstants' => 'applications/chatlog/constants/PhabricatorChatLogConstants.php',
|
||||
'PhabricatorChatLogController' => 'applications/chatlog/controller/PhabricatorChatLogController.php',
|
||||
'PhabricatorChatLogDAO' => 'applications/chatlog/storage/PhabricatorChatLogDAO.php',
|
||||
|
@ -2253,6 +2254,7 @@ phutil_register_library_map(array(
|
|||
),
|
||||
'PhabricatorChatLogChannelListController' => 'PhabricatorChatLogController',
|
||||
'PhabricatorChatLogChannelLogController' => 'PhabricatorChatLogController',
|
||||
'PhabricatorChatLogChannelQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||
'PhabricatorChatLogController' => 'PhabricatorController',
|
||||
'PhabricatorChatLogDAO' => 'PhabricatorLiskDAO',
|
||||
'PhabricatorChatLogEvent' =>
|
||||
|
|
|
@ -95,13 +95,6 @@ class AphrontDefaultApplicationConfiguration
|
|||
'keyboardshortcut/' => 'PhabricatorHelpKeyboardShortcutController',
|
||||
),
|
||||
|
||||
'/chatlog/' => array(
|
||||
'' =>
|
||||
'PhabricatorChatLogChannelListController',
|
||||
'channel/(?P<channel>[^/]+)/' =>
|
||||
'PhabricatorChatLogChannelLogController',
|
||||
),
|
||||
|
||||
'/notification/' => array(
|
||||
'(?:(?P<filter>all|unread)/)?'
|
||||
=> 'PhabricatorNotificationListController',
|
||||
|
|
44
src/applications/chatlog/PhabricatorChatLogChannelQuery.php
Normal file
44
src/applications/chatlog/PhabricatorChatLogChannelQuery.php
Normal file
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorChatLogChannelQuery
|
||||
extends PhabricatorCursorPagedPolicyAwareQuery {
|
||||
|
||||
private $channels;
|
||||
|
||||
public function withChannelNames(array $channels) {
|
||||
$this->channels = $channels;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function loadPage() {
|
||||
$table = new PhabricatorChatLogChannel();
|
||||
$conn_r = $table->establishConnection('r');
|
||||
|
||||
$data = queryfx_all(
|
||||
$conn_r,
|
||||
'SELECT * FROM %T c %Q %Q %Q',
|
||||
$table->getTableName(),
|
||||
$this->buildWhereClause($conn_r),
|
||||
$this->buildOrderClause($conn_r),
|
||||
$this->buildLimitClause($conn_r));
|
||||
|
||||
$logs = $table->loadAllFromArray($data);
|
||||
|
||||
return $logs;
|
||||
}
|
||||
|
||||
private function buildWhereClause($conn_r) {
|
||||
$where = array();
|
||||
|
||||
$where[] = $this->buildPagingClause($conn_r);
|
||||
|
||||
if ($this->channels) {
|
||||
$where[] = qsprintf(
|
||||
$conn_r,
|
||||
'channelName IN (%Ls)',
|
||||
$this->channels);
|
||||
}
|
||||
|
||||
return $this->formatWhereClause($where);
|
||||
}
|
||||
}
|
|
@ -3,11 +3,11 @@
|
|||
final class PhabricatorChatLogQuery
|
||||
extends PhabricatorCursorPagedPolicyAwareQuery {
|
||||
|
||||
private $channels;
|
||||
private $channelIDs;
|
||||
private $maximumEpoch;
|
||||
|
||||
public function withChannels(array $channels) {
|
||||
$this->channels = $channels;
|
||||
public function withChannelIDs(array $channel_ids) {
|
||||
$this->channelIDs = $channel_ids;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -45,11 +45,11 @@ final class PhabricatorChatLogQuery
|
|||
$this->maximumEpoch);
|
||||
}
|
||||
|
||||
if ($this->channels) {
|
||||
if ($this->channelIDs) {
|
||||
$where[] = qsprintf(
|
||||
$conn_r,
|
||||
'channel IN (%Ls)',
|
||||
$this->channels);
|
||||
'channelID IN (%Ld)',
|
||||
$this->channelIDs);
|
||||
}
|
||||
|
||||
return $this->formatWhereClause($where);
|
||||
|
|
|
@ -30,6 +30,8 @@ final class PhabricatorApplicationChatLog extends PhabricatorApplication {
|
|||
return array(
|
||||
'/chatlog/' => array(
|
||||
'' => 'PhabricatorChatLogChannelListController',
|
||||
'channel/(?P<channelID>[^/]+)/' =>
|
||||
'PhabricatorChatLogChannelLogController',
|
||||
),
|
||||
|
||||
);
|
||||
|
|
|
@ -33,9 +33,9 @@ final class ConduitAPI_chatlog_query_Method
|
|||
|
||||
$query = new PhabricatorChatLogQuery();
|
||||
|
||||
$channels = $request->getValue('channels');
|
||||
if ($channels) {
|
||||
$query->withChannels($channels);
|
||||
$channel_ids = $request->getValue('channelIDs');
|
||||
if ($channel_ids) {
|
||||
$query->withChannelIDs($channel_ids);
|
||||
}
|
||||
|
||||
$limit = $request->getValue('limit');
|
||||
|
@ -49,7 +49,7 @@ final class ConduitAPI_chatlog_query_Method
|
|||
$results = array();
|
||||
foreach ($logs as $log) {
|
||||
$results[] = array(
|
||||
'channel' => $log->getChannel(),
|
||||
'channelID' => $log->getChannelID(),
|
||||
'epoch' => $log->getEpoch(),
|
||||
'author' => $log->getAuthor(),
|
||||
'type' => $log->getType(),
|
||||
|
|
|
@ -61,7 +61,6 @@ final class ConduitAPI_chatlog_record_Method
|
|||
}
|
||||
|
||||
$obj = clone $template;
|
||||
$obj->setChannel($channel_name);
|
||||
$obj->setChannelID($channel->getID());
|
||||
$obj->setType(idx($log, 'type'));
|
||||
$obj->setAuthor(idx($log, 'author'));
|
||||
|
|
|
@ -4,24 +4,23 @@ final class PhabricatorChatLogChannelListController
|
|||
extends PhabricatorChatLogController {
|
||||
|
||||
public function processRequest() {
|
||||
$request = $this->getRequest();
|
||||
$user = $request->getUser();
|
||||
|
||||
$table = new PhabricatorChatLogEvent();
|
||||
|
||||
$channels = queryfx_all(
|
||||
$table->establishConnection('r'),
|
||||
'SELECT DISTINCT channel FROM %T',
|
||||
$table->getTableName());
|
||||
$channels = id(new PhabricatorChatLogChannelQuery())
|
||||
->setViewer($user)
|
||||
->execute();
|
||||
|
||||
$rows = array();
|
||||
foreach ($channels as $channel) {
|
||||
$name = $channel['channel'];
|
||||
$rows[] = array(
|
||||
phutil_tag(
|
||||
'a',
|
||||
array(
|
||||
'href' => '/chatlog/channel/'.phutil_escape_uri($name).'/',
|
||||
'href' =>
|
||||
'/chatlog/channel/'.$channel->getID().'/',
|
||||
),
|
||||
$name));
|
||||
$channel->getChannelName()));
|
||||
}
|
||||
|
||||
$table = new AphrontTableView($rows);
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
final class PhabricatorChatLogChannelLogController
|
||||
extends PhabricatorChatLogController {
|
||||
|
||||
private $channel;
|
||||
private $channelID;
|
||||
|
||||
public function willProcessRequest(array $data) {
|
||||
$this->channel = $data['channel'];
|
||||
$this->channelID = $data['channelID'];
|
||||
}
|
||||
|
||||
public function processRequest() {
|
||||
|
@ -22,7 +22,7 @@ final class PhabricatorChatLogChannelLogController
|
|||
|
||||
$query = id(new PhabricatorChatLogQuery())
|
||||
->setViewer($user)
|
||||
->withChannels(array($this->channel));
|
||||
->withChannelIDs(array($this->channelID));
|
||||
|
||||
|
||||
list($after, $before, $map) = $this->getPagingParameters($request, $query);
|
||||
|
@ -140,9 +140,9 @@ final class PhabricatorChatLogChannelLogController
|
|||
array(
|
||||
hsprintf(
|
||||
'<div class="phabricator-chat-log-panel">%s<br />%s%s</div>',
|
||||
$form,
|
||||
$form->render(),
|
||||
phutil_tag('table', array('class' => 'phabricator-chat-log'), $out),
|
||||
$pager),
|
||||
$pager->render()),
|
||||
),
|
||||
array(
|
||||
'title' => 'Channel Log',
|
||||
|
|
Loading…
Reference in a new issue