[MediaWiki-commits] [Gerrit] mediawiki/core[master]: RCFilters: Live Update: download less data

2017-09-06 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/376041 )

Change subject: RCFilters: Live Update: download less data
..


RCFilters: Live Update: download less data

Make ChangesListSpecialPage respect action=render
to exclude the MW chrome (header, logo, sidebar, etc).

Introduce peek=1 in ChangesListSpecialPage to skip
the form and changes list rendering and return
200 when there is new data and 304 (not modified)
where there isn't.

Together, they reduce the page size from 49.9k to 275b on polling
and eliminate most HTTP 404 console errors.

Bug: T173613
Change-Id: I0aec878ae80e22814b196b26e944db8c78a5f91a
---
M includes/specialpage/ChangesListSpecialPage.php
M resources/src/mediawiki.rcfilters/mw.rcfilters.Controller.js
2 files changed, 29 insertions(+), 6 deletions(-)

Approvals:
  Catrope: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/specialpage/ChangesListSpecialPage.php 
b/includes/specialpage/ChangesListSpecialPage.php
index 5f54404..04d03f5 100644
--- a/includes/specialpage/ChangesListSpecialPage.php
+++ b/includes/specialpage/ChangesListSpecialPage.php
@@ -519,14 +519,23 @@
public function execute( $subpage ) {
$this->rcSubpage = $subpage;
 
-   $this->setHeaders();
-   $this->outputHeader();
-   $this->addModules();
-
$rows = $this->getRows();
$opts = $this->getOptions();
if ( $rows === false ) {
$rows = new FakeResultWrapper( [] );
+   }
+
+   // Used by Structured UI app to get results without MW chrome
+   if ( $this->getRequest()->getVal( 'action' ) === 'render' ) {
+   $this->getOutput()->setArticleBodyOnly( true );
+   }
+
+   // Used by "live update" and "view newest" to check
+   // if there's new changes with minimal data transfer
+   if ( $this->getRequest()->getBool( 'peek' ) ) {
+   $code = $rows->numRows() > 0 ? 200 : 304;
+   $this->getOutput()->setStatusCode( $code );
+   return;
}
 
$batch = new LinkBatch;
@@ -542,6 +551,10 @@
}
}
$batch->execute();
+
+   $this->setHeaders();
+   $this->outputHeader();
+   $this->addModules();
$this->webOutput( $rows, $opts );
 
$rows->free();
diff --git a/resources/src/mediawiki.rcfilters/mw.rcfilters.Controller.js 
b/resources/src/mediawiki.rcfilters/mw.rcfilters.Controller.js
index 81bfb47..8d0aa05 100644
--- a/resources/src/mediawiki.rcfilters/mw.rcfilters.Controller.js
+++ b/resources/src/mediawiki.rcfilters/mw.rcfilters.Controller.js
@@ -561,6 +561,7 @@
'liveUpdate',
{
limit: 1,
+   peek: 1, // bypasses all UI
from: this.changesListModel.getNextFrom()
}
);
@@ -1130,6 +1131,7 @@
 
counterId = counterId || 'updateChangesList';
params = params || {};
+   params.action = 'render'; // bypasses MW chrome
 
uri.extend( params );
 
@@ -1149,7 +1151,7 @@
 
return $.ajax( uri.toString(), { contentType: 'html' } )
.then(
-   function ( html ) {
+   function ( html, reason ) {
var $parsed,
pieces;
 
@@ -1157,7 +1159,15 @@
return $.Deferred().reject();
}
 
-   $parsed = $( $.parseHTML( html ) );
+   if ( params.peek && reason === 
'notmodified' ) {
+   return {
+   changes: 'NO_RESULTS'
+   };
+   }
+
+   // Because of action=render, the 
response is a list of nodes.
+   // It has to be put under a root node 
so it can be queried.
+   $parsed = $( '' ).append( $( 
$.parseHTML( html ) ) );
 
pieces = {
// Changes list

-- 
To view, visit https://gerrit.wikimedia.org/r/376041
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I0aec878ae80e22814b196b26e944db8c78a5f91a

[MediaWiki-commits] [Gerrit] mediawiki/core[master]: RCFilters: Live Update: download less data

2017-09-05 Thread Sbisson (Code Review)
Sbisson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/376041 )

Change subject: RCFilters: Live Update: download less data
..

RCFilters: Live Update: download less data

Add useskin=apioutput to the URL to bypass most
of the MW chrome.

Introduce peek=1 in ChangesListSpecialPage to skip
the rendering and return a code indicating of there's data.

Together, they reduce the page size from 49.9k to 6.3k.

Bug: T173613
Change-Id: I0aec878ae80e22814b196b26e944db8c78a5f91a
---
M includes/specialpage/ChangesListSpecialPage.php
M resources/src/mediawiki.rcfilters/mw.rcfilters.Controller.js
2 files changed, 14 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/41/376041/1

diff --git a/includes/specialpage/ChangesListSpecialPage.php 
b/includes/specialpage/ChangesListSpecialPage.php
index acd5d14..520232c 100644
--- a/includes/specialpage/ChangesListSpecialPage.php
+++ b/includes/specialpage/ChangesListSpecialPage.php
@@ -519,14 +519,18 @@
public function execute( $subpage ) {
$this->rcSubpage = $subpage;
 
-   $this->setHeaders();
-   $this->outputHeader();
-   $this->addModules();
-
$rows = $this->getRows();
$opts = $this->getOptions();
if ( $rows === false ) {
$rows = new FakeResultWrapper( [] );
+   }
+
+   // Used by "live update" and "view newest" to minimize
+   // the amount of data downloaded on polling
+   if ( $this->getRequest()->getBool( 'peek' ) ) {
+   $code = $rows->numRows() > 0 ? 200 : 404;
+   $this->getOutput()->setStatusCode( $code );
+   return;
}
 
$batch = new LinkBatch;
@@ -542,6 +546,10 @@
}
}
$batch->execute();
+
+   $this->setHeaders();
+   $this->outputHeader();
+   $this->addModules();
$this->webOutput( $rows, $opts );
 
$rows->free();
diff --git a/resources/src/mediawiki.rcfilters/mw.rcfilters.Controller.js 
b/resources/src/mediawiki.rcfilters/mw.rcfilters.Controller.js
index 81bfb47..1644ebc 100644
--- a/resources/src/mediawiki.rcfilters/mw.rcfilters.Controller.js
+++ b/resources/src/mediawiki.rcfilters/mw.rcfilters.Controller.js
@@ -561,6 +561,8 @@
'liveUpdate',
{
limit: 1,
+   peek: 1, // bypasses RC form
+   useskin: 'apioutput', // bypasses MW chrome
from: this.changesListModel.getNextFrom()
}
);

-- 
To view, visit https://gerrit.wikimedia.org/r/376041
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0aec878ae80e22814b196b26e944db8c78a5f91a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Sbisson 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits