Legoktm has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/315991

Change subject: linter: Only send API requests if the revision is the latest
......................................................................

linter: Only send API requests if the revision is the latest

We also verify this in the MW API extension, but this will reduce the
number of API requests that are sent.

Change-Id: Idc64c9baf389f590d91aabda7d8226304425d992
---
M lib/logger/linter.js
1 file changed, 18 insertions(+), 14 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/parsoid 
refs/changes/91/315991/1

diff --git a/lib/logger/linter.js b/lib/logger/linter.js
index 3d0cdf7..dcea874 100644
--- a/lib/logger/linter.js
+++ b/lib/logger/linter.js
@@ -19,20 +19,24 @@
                if (!this._env.conf.parsoid.linterAPI) {
                        console.log(this.buffer);
                } else {
-                       request.post(
-                               this._env.conf.parsoid.linterAPI,
-                               { form: {
-                                       data: JSON.stringify(this.buffer),
-                                       page: this._env.page.name,
-                                       revision: 
this._env.page.meta.revision.revid,
-                                       action: 'record-lint',
-                                       format: 'json',
-                                       formatversion: 2,
-                               }, },
-                               function(error, response, body) {
-                                       console.log(body);
-                               }
-                       );
+                       // Only send the request if it is
+                       // the latest revision
+                       if ( this._env.page.meta.revision.revid == 
this._env.page.latest ) {
+                               request.post(
+                                       this._env.conf.parsoid.linterAPI,
+                                       { form: {
+                                               data: 
JSON.stringify(this.buffer),
+                                               page: this._env.page.name,
+                                               revision: 
this._env.page.meta.revision.revid,
+                                               action: 'record-lint',
+                                               format: 'json',
+                                               formatversion: 2,
+                                       }, },
+                                       function(error, response, body) {
+                                               console.log(body);
+                                       }
+                               );
+                       }
                }
                this.buffer = [];
                return;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Idc64c9baf389f590d91aabda7d8226304425d992
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Legoktm <legoktm.wikipe...@gmail.com>

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

Reply via email to