jenkins-bot has submitted this change and it was merged.

Change subject: Only provide needed page titles to RB for most-read and news 
responses
......................................................................


Only provide needed page titles to RB for most-read and news responses

Omit needless extra processing since RB fetches metadata on its own.

Tested locally against RB and all full feed content responses are as
expected.

Bug: T146041
Change-Id: Idc387bea82d9d596c3c6c68d4bf6dee2bc89a81e
---
M lib/feed/most-read.js
M lib/feed/news.js
M lib/mwapi.js
M spec.yaml
M test/features/most-read/most-read.js
M test/features/news/news.js
6 files changed, 5 insertions(+), 74 deletions(-)

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



diff --git a/lib/feed/most-read.js b/lib/feed/most-read.js
index 8e95f14..13d55c9 100644
--- a/lib/feed/most-read.js
+++ b/lib/feed/most-read.js
@@ -57,11 +57,10 @@
                  && response.body.items[0];
         var rankedTitles = items && items.articles;
         resultsDate = items && items.year + '-' + items.month + '-' + 
items.day + 'Z';
-
         goodTitles = blacklist.filter(rankedTitles)
                               .slice(0, mwapi.API_QUERY_MAX_TITLES);
         queryTitlesList = constructQueryListFrom(goodTitles);
-        return mwapi.getFeedPageListMetadata(app, req, 
queryTitlesList.join('|'), false);
+        return mwapi.getMostReadMetadata(app, req, queryTitlesList.join('|'));
     }).then(function (response) {
         api.checkResponseStatus(response);
 
@@ -81,13 +80,9 @@
 
         var results = goodTitles.map(function(entry) {
             return Object.assign(entry, {
-                normalizedtitle: entry.title,
                 title: entry.article,
-                description: entry.terms
-                             && entry.terms.description
-                             && entry.terms.description[0],
-                thumbnail: entry.thumbnail,
                 article: undefined,
+                fromencoded: undefined,
                 ns: undefined,
                 terms: undefined,
                 revisions: undefined
diff --git a/lib/feed/news.js b/lib/feed/news.js
index 27449a6..4932193 100644
--- a/lib/feed/news.js
+++ b/lib/feed/news.js
@@ -78,40 +78,6 @@
             story.story = stories[j].innerHTML;
             result.payload.push(story);
         }
-        return mwapi.getFeedPageListMetadata(app, req, linkTitles.join('|'), 
true);
-    }).then(function(response) {
-        api.checkResponseStatus(response);
-
-        var query = response.body && response.body.query;
-        var normalizations = query && query.normalized;
-        var pages = query && query.pages;
-
-        if (normalizations) {
-            mUtil.adjustMemberKeys(normalizations, [['title', 'from'],
-                                                    ['normalizedtitle', 
'to']]);
-        }
-        mUtil.adjustMemberKeys(pages, [['normalizedtitle', 'title']]);
-        mUtil.mergeByProp(pages, normalizations, 'normalizedtitle');
-        mUtil.fillInMemberKeys(pages, [['title', 'normalizedtitle']]);
-
-        var pageResults = {};
-
-        pages.forEach(function(page) {
-            pageResults[page.title] = Object.assign(page, {
-                description: page.terms
-                             && page.terms.description
-                             && page.terms.description[0],
-                terms: undefined
-            });
-        });
-
-        result.payload.forEach(function(story) {
-            mUtil.mergeByProp(story.links, pageResults, 'title', false);
-            story.links = story.links.filter(function(link) {
-                return !link.hasOwnProperty('missing');
-            });
-        });
-
         return result;
     });
 }
diff --git a/lib/mwapi.js b/lib/mwapi.js
index 2616789..3f094cf 100644
--- a/lib/mwapi.js
+++ b/lib/mwapi.js
@@ -234,16 +234,11 @@
     };
 };
 
-mwapi.getFeedPageListMetadata = function(app, req, titlesList, 
needFeatureImage) {
+mwapi.getMostReadMetadata = function(app, req, titlesList) {
     var query = {
         action: 'query',
         format: 'json',
         formatversion: 2,
-        prop: 'pageimages|pageterms',
-        piprop: 'thumbnail',
-        pilimit: mwapi.API_QUERY_MAX_TITLES,
-        pithumbsize: needFeatureImage ? mwapi.LEAD_IMAGE_XL : 
mwapi.CARD_THUMB_LIST_ITEM_SIZE,
-        wbptterms: 'description',
         meta: 'siteinfo',
         siprop: 'general',
         titles: titlesList
diff --git a/spec.yaml b/spec.yaml
index bfa730e..5529d9c 100644
--- a/spec.yaml
+++ b/spec.yaml
@@ -112,18 +112,13 @@
 #                  - views: /.+/
 #                    rank: /.+/
 #                    title: /.+/
-#                    pageid: /.+/
-#                    normalizedtitle: /.+/
 #              random:
 #                items:
 #                  - title: /.+/
 #              news:
 #                - story: /.+/
 #                  links:
-#                    - pageid: /.+/
-#                      ns: /.+/
-#                      normalizedtitle: /.+/
-#                      title: /.+/
+#                    - title: /.+/
 #              image:
 #                title: /.+/
 #                description:
@@ -288,8 +283,6 @@
                 - views: /.+/
                   rank: /.+/
                   title: /.+/
-                  pageid: /.+/
-                  normalizedtitle: /.+/
   # from routes/random.js
   /{domain}/v1/page/random/title:
     get:
@@ -324,10 +317,7 @@
             body:
               - story: /.+/
                 links:
-                  - pageid: /.+/
-                    ns: /.+/
-                    normalizedtitle: /.+/
-                    title: /.+/
+                  - title: /.+/
   # from routes/media.js
   /{domain}/v1/page/media/{title}:
     get:
diff --git a/test/features/most-read/most-read.js 
b/test/features/most-read/most-read.js
index 4e355d4..2dc1c16 100644
--- a/test/features/most-read/most-read.js
+++ b/test/features/most-read/most-read.js
@@ -28,10 +28,6 @@
               assert.ok(res.body.articles.length);
               res.body.articles.forEach(function (elem) {
                   assert.ok(elem.title, 'title should be present');
-                  assert.ok(elem.normalizedtitle, 'normalizedtitle should be 
present');
-                  assert.ok(elem.views, 'views should be present');
-                  assert.ok(elem.rank, 'rank should be present');
-                  assert.ok(elem.pageid, 'pageid should be present');
                   assert.ok(BLACKLIST.indexOf(elem.title) === -1, 'Should not 
include blacklisted title');
                   assert.ok(elem.title !== 'Main_Page', 'Should not include 
the Main Page');
                   assert.ok(elem.title.indexOf('Special:') === -1, 'Should not 
include Special page');
@@ -46,10 +42,6 @@
               assert.ok(res.body.articles.length);
               res.body.articles.forEach(function (elem) {
                   assert.ok(elem.title, 'title should be present');
-                  assert.ok(elem.normalizedtitle, 'normalizedtitle should be 
present');
-                  assert.ok(elem.views, 'views should be present');
-                  assert.ok(elem.rank, 'rank should be present');
-                  assert.ok(elem.pageid, 'pageid should be present');
                   assert.ok(BLACKLIST.indexOf(elem.title) === -1, 'Should not 
include blacklisted title');
                   assert.ok(elem.title !== 'Main_Page', 'Should not include 
the Main Page');
                   assert.ok(elem.title.indexOf('Special:') === -1, 'Should not 
include Special page');
diff --git a/test/features/news/news.js b/test/features/news/news.js
index 3991c07..5f4e125 100644
--- a/test/features/news/news.js
+++ b/test/features/news/news.js
@@ -54,16 +54,9 @@
                     res.body.forEach(function (elem) {
                         assert.ok(elem.story, 'story should be present');
                         assert.ok(elem.links, 'links should be present');
-
                         elem.links.forEach(function (link) {
-                            assert.ok(link.pageid, 'page id should be present 
>>> ' + JSON.stringify(link));
-                            assert.ok(link.ns !== undefined, 'namespace should 
be present'); // 0 is falsey but good
                             assert.ok(link.title, 'title should be present');
-                            assert.ok(link.normalizedtitle, 'normalized title 
should be present');
                             assert.ok(link.missing === undefined, 'no missing 
links should be present');
-                            if (link.thumbnail) {
-                                assert.ok(link.thumbnail.source, 'thumbnail 
should have source URL');
-                            }
                         });
                     });
                 });

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Idc387bea82d9d596c3c6c68d4bf6dee2bc89a81e
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: Mholloway <mhollo...@wikimedia.org>
Gerrit-Reviewer: BearND <bsitzm...@wikimedia.org>
Gerrit-Reviewer: Dbrant <dbr...@wikimedia.org>
Gerrit-Reviewer: Fjalapeno <cfl...@wikimedia.org>
Gerrit-Reviewer: GWicke <gwi...@wikimedia.org>
Gerrit-Reviewer: Jhernandez <jhernan...@wikimedia.org>
Gerrit-Reviewer: Mhurd <mh...@wikimedia.org>
Gerrit-Reviewer: Mobrovac <mobro...@wikimedia.org>
Gerrit-Reviewer: Niedzielski <sniedziel...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to