mirror of
https://we.phorge.it/source/phorge.git
synced 2025-03-26 11:10:16 +01:00
Chatlog - add a pager
Summary: 'cuz I miss out on chat room goodness and can't paginate around in the current version Test Plan: setup a phabot and spammed it in phabot-test. with new test data, set $page_limit = 1 and paged about -- looks good! Reviewers: epriestley Reviewed By: epriestley CC: aran, epriestley Maniphest Tasks: T990 Differential Revision: https://secure.phabricator.com/D2032
This commit is contained in:
parent
7ad68e63e4
commit
e696619dd1
6 changed files with 22 additions and 25 deletions
|
@ -303,7 +303,8 @@ final class AphrontRequest {
|
|||
final public function getRequestURI() {
|
||||
$get = $_GET;
|
||||
unset($get['__path__']);
|
||||
return id(new PhutilURI($this->getPath()))->setQueryParams($get);
|
||||
$path = phutil_escape_uri($this->getPath());
|
||||
return id(new PhutilURI($path))->setQueryParams($get);
|
||||
}
|
||||
|
||||
final public function isDialogFormPost() {
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
phutil_require_module('phabricator', 'aphront/exception/csrf');
|
||||
phutil_require_module('phabricator', 'infrastructure/env');
|
||||
|
||||
phutil_require_module('phutil', 'markup');
|
||||
phutil_require_module('phutil', 'parser/uri');
|
||||
phutil_require_module('phutil', 'utils');
|
||||
|
||||
|
|
|
@ -27,13 +27,19 @@ final class PhabricatorChatLogChannelLogController
|
|||
|
||||
public function processRequest() {
|
||||
|
||||
$request = $this->getRequest();
|
||||
$user = $request->getUser();
|
||||
$request = $this->getRequest();
|
||||
$user = $request->getUser();
|
||||
$offset = $request->getInt('offset', 0);
|
||||
$page_size = 1000;
|
||||
$pager = new AphrontPagerView();
|
||||
$request_uri = $request->getRequestURI();
|
||||
$pager->setURI($request_uri, 'offset');
|
||||
$pager->setPageSize($page_size);
|
||||
$pager->setOffset($offset);
|
||||
|
||||
$query = new PhabricatorChatLogQuery();
|
||||
$query->withChannels(array($this->channel));
|
||||
$query->setLimit(1000);
|
||||
$logs = $query->execute();
|
||||
$logs = $query->executeWithPager($pager);
|
||||
|
||||
require_celerity_resource('phabricator-chatlog-css');
|
||||
|
||||
|
@ -78,7 +84,10 @@ final class PhabricatorChatLogChannelLogController
|
|||
|
||||
|
||||
return $this->buildStandardPageResponse(
|
||||
implode("\n", $out),
|
||||
array(
|
||||
implode("\n", $out),
|
||||
$pager
|
||||
),
|
||||
array(
|
||||
'title' => 'Channel Log',
|
||||
));
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
phutil_require_module('phabricator', 'applications/chatlog/controller/base');
|
||||
phutil_require_module('phabricator', 'applications/chatlog/query');
|
||||
phutil_require_module('phabricator', 'infrastructure/celerity/api');
|
||||
phutil_require_module('phabricator', 'view/control/pager');
|
||||
phutil_require_module('phabricator', 'view/utils');
|
||||
|
||||
phutil_require_module('phutil', 'markup');
|
||||
|
|
|
@ -16,35 +16,20 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
final class PhabricatorChatLogQuery {
|
||||
|
||||
final class PhabricatorChatLogQuery extends PhabricatorOffsetPagedQuery {
|
||||
private $channels;
|
||||
|
||||
private $limit;
|
||||
|
||||
public function withChannels(array $channels) {
|
||||
$this->channels = $channels;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setLimit($limit) {
|
||||
$this->limit = $limit;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function execute() {
|
||||
$table = new PhabricatorChatLogEvent();
|
||||
$table = new PhabricatorChatLogEvent();
|
||||
$conn_r = $table->establishConnection('r');
|
||||
|
||||
$where_clause = $this->buildWhereClause($conn_r);
|
||||
|
||||
$limit_clause = '';
|
||||
if ($this->limit) {
|
||||
$limit_clause = qsprintf(
|
||||
$conn_r,
|
||||
'LIMIT %d',
|
||||
$this->limit);
|
||||
}
|
||||
$limit_clause = $this->buildLimitClause($conn_r);
|
||||
|
||||
$data = queryfx_all(
|
||||
$conn_r,
|
||||
|
@ -76,5 +61,4 @@ final class PhabricatorChatLogQuery {
|
|||
|
||||
return $where;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
|
||||
phutil_require_module('phabricator', 'applications/chatlog/storage/event');
|
||||
phutil_require_module('phabricator', 'infrastructure/query/offsetpaged');
|
||||
phutil_require_module('phabricator', 'storage/qsprintf');
|
||||
phutil_require_module('phabricator', 'storage/queryfx');
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue