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

Change subject: Remove aggregated endpoint
......................................................................


Remove aggregated endpoint

RESTBase now handles aggregation, so maintaining this as part of MCS is
no longer necessary or desirable.

Adds tests to ensure the correct behavior of the aggregated query flag for
relevant individual endpoints.

Bug: T145221
Change-Id: I453a1f729492a6550661df7bd0e050f04e81f8c0
---
M lib/mobile-util.js
D routes/aggregated.js
M spec.yaml
D test/features/aggregated/aggregated.js
M test/features/definition/definition.js
M test/features/featured-image/pagecontent.js
M test/features/most-read/most-read.js
M test/features/news/news.js
8 files changed, 37 insertions(+), 218 deletions(-)

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



diff --git a/lib/mobile-util.js b/lib/mobile-util.js
index d32108e..84e2e2f 100644
--- a/lib/mobile-util.js
+++ b/lib/mobile-util.js
@@ -10,7 +10,6 @@
     mobileSections: { name: 'mobile-sections', version: '0.8.0' },
     definition: { name: 'definition', version: '0.7.0' },
 
-    aggregatedFeed: { name: 'aggregated-feed', version: '0.5.0' },
     random: { name: 'random', version: '0.6.0' },
 
     unpublished: { name: 'unpublished', version: '0.0.0' }
diff --git a/routes/aggregated.js b/routes/aggregated.js
deleted file mode 100644
index 35afaee..0000000
--- a/routes/aggregated.js
+++ /dev/null
@@ -1,66 +0,0 @@
-/**
- * Route for fetching aggregated app feed content.
- */
-
-'use strict';
-
-var BBPromise = require('bluebird');
-var preq = require('preq');
-var sUtil = require('../lib/util');
-var mUtil = require('../lib/mobile-util');
-var mwapi = require('../lib/mwapi');
-var dateUtil = require('../lib/dateUtil');
-var mostRead = require('../lib/feed/most-read');
-var featured = require('../lib/feed/featured');
-var featuredImage = require('../lib/feed/featured-image');
-var random = require('../lib/feed/random');
-var news = require('../lib/feed/news');
-
-/**
- * The main router object
- */
-var router = sUtil.router();
-
-/**
- * The main application object reported when this module is require()d
- */
-var app;
-
-/**
- * GET {domain}/api/rest_v1/feed/featured/{yyyy}/{mm}/{dd}
- * Returns aggregated feed content for the date requested.
- */
-router.get('/featured/:yyyy/:mm/:dd', function (req, res) {
-    var dateString = dateUtil.dateStringFrom(req);
-    // signal that this is a request for aggregated resources
-    req.query = req.query || {};
-    req.query.aggregated = true;
-    return BBPromise.props({
-        tfa: featured.promise(app, req),
-        mostread: mostRead.promise(app, req),
-        random: random.promise(app, req),
-        news: news.promise(app, req),
-        image: featuredImage.promise(app, req)
-    }) .then(function (response) {
-        var aggregate = {
-            tfa: response.tfa.payload,
-            random: mwapi.buildTitleResponse(response.random.payload),
-            mostread: response.mostread.payload,
-            news: response.news.payload,
-            image: response.image.payload
-        };
-        res.status(200);
-        mUtil.setETagToValue(res, mUtil.getDateStringEtag(dateString));
-        mUtil.setContentType(res, mUtil.CONTENT_TYPES.aggregatedFeed);
-        res.json(aggregate).end();
-    });
-});
-
-module.exports = function (appObj) {
-    app = appObj;
-    return {
-        path: '/feed',
-        api_version: 1,
-        router: router
-    };
-};
diff --git a/spec.yaml b/spec.yaml
index 5529d9c..3733239 100644
--- a/spec.yaml
+++ b/spec.yaml
@@ -55,83 +55,6 @@
               description: /.+/
               version: /.+/
               home: /.+/
-  # from routes/aggregated.js
-  /{domain}/v1/feed/featured/{yyyy}/{mm}/{dd}:
-    get:
-      tags:
-        - Aggregated feed content for a given date
-      description: Provides aggregated feed content (featured article of the 
day, previous day's most-read articles, news, random article, featured image, 
featured video)
-      produces:
-        - application/json
-      parameters:
-        - name: yyyy
-          in: path
-          description: "Year the aggregated content is requested for"
-          type: string
-          required: true
-          minimum: "2016"
-          maximum: "2999"
-        - name: mm
-          in: path
-          description: "Month the aggregated content is requested for"
-          type: string
-          required: true
-          minimum: "01"
-          maximum: "12"
-        - name: dd
-          in: path
-          description: "Day of the month the aggregated content is requested 
for"
-          type: string
-          required: true
-          minimum: "01"
-          maximum: "31"
-      x-monitor: false
-#      x-amples:
-#        - title: retrieve aggregated feed content for April 29, 2016
-#          request:
-#            params:
-#              yyyy: "2016"
-#              mm: "04"
-#              dd: "29"
-#          response:
-#            status: 200
-#            headers:
-#              content-type: application/json
-#            body:
-#              tfa:
-#                title: /.+/
-#                description: /.+/
-#                extract: /.+/
-#                thumbnail:
-#                  source: /.+/
-#                  width: /.+/
-#                  height: /.+/
-#              mostread:
-#                date: /.+/
-#                articles:
-#                  - views: /.+/
-#                    rank: /.+/
-#                    title: /.+/
-#              random:
-#                items:
-#                  - title: /.+/
-#              news:
-#                - story: /.+/
-#                  links:
-#                    - title: /.+/
-#              image:
-#                title: /.+/
-#                description:
-#                  text: /.+/
-#                  lang: /.+/
-#                image:
-#                  source: /.+/
-#                  width: /.+/
-#                  height: /.+/
-#                thumbnail:
-#                  source: /.+/
-#                  width: /.+/
-#                  height: /.+/
   # from routes/featured.js
   /{domain}/v1/page/featured/{yyyy}/{mm}/{dd}:
     get:
diff --git a/test/features/aggregated/aggregated.js 
b/test/features/aggregated/aggregated.js
deleted file mode 100644
index dec2950..0000000
--- a/test/features/aggregated/aggregated.js
+++ /dev/null
@@ -1,72 +0,0 @@
-'use strict';
-
-
-var preq   = require('preq');
-var assert = require('../../utils/assert');
-var server = require('../../utils/server');
-var headers = require('../../utils/headers');
-var dateUtil = require('../../../lib/dateUtil');
-
-var date = new Date();
-var dateString = date.getUTCFullYear() + '/' + dateUtil.pad(date.getUTCMonth() 
+ 1) + '/' + dateUtil.pad(date.getUTCDate());
-
-var yesterday = new Date(Date.now() - dateUtil.ONE_DAY);
-var yesterdayString = yesterday.getUTCFullYear() + '-'
-                    + dateUtil.pad(yesterday.getUTCMonth() + 1) + '-'
-                    + dateUtil.pad(yesterday.getUTCDate())
-                    + 'Z';
-
-describe('aggregated feed endpoint', function() {
-    this.timeout(20000);
-
-    before(function () { return server.start(); });
-
-    it('should respond to GET request with expected headers, incl. CORS and 
CSP headers', function() {
-        return headers.checkHeaders(server.config.uri + 
'en.wikipedia.org/v1/feed/featured/' + dateString);
-    });
-
-    it('Response should contain all expected properties', function() {
-        return preq.get({ uri: server.config.uri + 
'en.wikipedia.org/v1/feed/featured/' + dateString })
-            .then(function(res) {
-                var body = res.body;
-                assert.deepEqual(res.status, 200);
-                assert.ok(body.hasOwnProperty('tfa'), 'Should have today\'s 
featured article');
-                if (body.hasOwnProperty('mostread')) {
-                      assert.ok(body.mostread.articles.length, 'Should have 
most-read articles');
-                      assert.deepEqual(body.mostread.date, yesterdayString);
-                }
-                assert.ok(body.hasOwnProperty('random'), 'Should have random 
article');
-                assert.ok(body.hasOwnProperty('news'), 'Should have today\'s 
news');
-                assert.ok(body.hasOwnProperty('image'), 'Should have today\'s 
featured image');
-            });
-    });
-
-    it('non-enwiki doesn\'t have tfa or news entries', function() {
-        return preq.get({ uri: server.config.uri + 
'fr.wikipedia.org/v1/feed/featured/' + dateString })
-            .then(function(res) {
-                var body = res.body;
-                assert.deepEqual(res.status, 200);
-                assert.ok(!body.hasOwnProperty('tfa'), 'Should not have 
today\'s featured article');
-                assert.ok(!body.hasOwnProperty('news'), 'Should not have 
today\'s news');
-                if (body.hasOwnProperty('mostread')) {
-                      assert.ok(body.mostread.articles.length, 'Should have 
most-read articles');
-                }
-                assert.ok(body.hasOwnProperty('random'), 'Should have random 
article');
-                assert.ok(body.hasOwnProperty('image'), 'Should have today\'s 
featured image');
-            });
-    });
-
-    it('featured image for 2016/07/05 has expected properties', function() {
-        return preq.get({ uri: server.config.uri + 
'ja.wikipedia.org/v1/feed/featured/2016/07/05' })
-            .then(function(res) {
-                var image = res.body.image;
-                assert.deepEqual(res.status, 200);
-                assert.ok(image, 'Should have today\'s featured image');
-                assert.deepEqual(image.title, 'File:Amari Agia Anna Fresco 
02.JPG');
-                assert.deepEqual(image.thumbnail.source, 
'https://upload.wikimedia.org/wikipedia/commons/thumb/6/64/Amari_Agia_Anna_Fresco_02.JPG/640px-Amari_Agia_Anna_Fresco_02.JPG');
-                assert.deepEqual(image.image.source, 
'https://upload.wikimedia.org/wikipedia/commons/6/64/Amari_Agia_Anna_Fresco_02.JPG');
-                assert.deepEqual(image.description.text, 'Byzantine fresco of 
Saint Andrew of Crete in the church of Agia Anna (Αγία Άννα), Amari Valley, 
Crete. The frescoes are dated 1225 and the oldest dated frescoes in Crete.');
-                assert.deepEqual(image.description.lang, 'en');
-            });
-    });
-});
diff --git a/test/features/definition/definition.js 
b/test/features/definition/definition.js
index 748dd6b..f51359b 100644
--- a/test/features/definition/definition.js
+++ b/test/features/definition/definition.js
@@ -85,5 +85,5 @@
             assert.status(res, 200);
             assert.ok(Object.keys(res).length !== 0);
         });
-    })
+    });
 });
diff --git a/test/features/featured-image/pagecontent.js 
b/test/features/featured-image/pagecontent.js
index 3d03c72..1f11271 100644
--- a/test/features/featured-image/pagecontent.js
+++ b/test/features/featured-image/pagecontent.js
@@ -82,4 +82,13 @@
                 assert.equal(err.body.type, 'not_found');
             });
     });
+
+    it('404 for date with no featured image should be suppressed when 
aggregated flag is set', function() {
+        return preq.get({ uri: server.config.uri + 
'en.wikipedia.org/v1/media/image/featured/2002/09/12',
+                          query: { aggregated: true }})
+          .then(function(res) {
+              assert.status(res, 200);
+              assert.deepEqual(!!res.body, false, 'Expected the body to be 
empty');
+          });
+    });
 });
diff --git a/test/features/most-read/most-read.js 
b/test/features/most-read/most-read.js
index 2dc1c16..25a1b8a 100644
--- a/test/features/most-read/most-read.js
+++ b/test/features/most-read/most-read.js
@@ -9,8 +9,11 @@
 var BLACKLIST = require('../../../etc/feed/blacklist');
 
 var date = new Date();
-date.setDate(date.getDate() - 5);
+var originalDate = date.getDate();
+date.setDate(originalDate - 5);
 var dateString = date.getUTCFullYear() + '/' + dateUtil.pad(date.getUTCMonth() 
+ 1) + '/' + dateUtil.pad(date.getUTCDate());
+date.setDate(originalDate + 5);
+var futureDateString = date.getUTCFullYear() + '/' + 
dateUtil.pad(date.getUTCMonth() + 1) + '/' + dateUtil.pad(date.getUTCDate());
 
 describe('most-read articles', function() {
     this.timeout(20000);
@@ -20,6 +23,7 @@
     it('should respond to GET request with expected headers, incl. CORS and 
CSP headers', function() {
         return headers.checkHeaders(server.config.uri + 
'en.wikipedia.org/v1/page/most-read/' + dateString);
     });
+
     it('results list should have expected properties', function() {
         return preq.get({ uri: server.config.uri + 
'en.wikipedia.org/v1/page/most-read/' + dateString })
           .then(function(res) {
@@ -34,6 +38,7 @@
               });
           });
     });
+
     it('should load successfully even with no normalizations from the MW API', 
function() {
         return preq.get({ uri: server.config.uri + 
'ja.wikipedia.org/v1/page/most-read/2016/06/15' })
           .then(function(res) {
@@ -48,10 +53,20 @@
               });
           });
     });
+
     it('Request to mobile domain should complete successfully', function() {
         return preq.get({ uri: server.config.uri + 
'en.m.wikipedia.org/v1/page/most-read/' + dateString })
           .then(function(res) {
               assert.deepEqual(res.status, 200);
           });
     });
+
+    it('404 for future date should be suppressed when aggregated flag is set', 
function() {
+        return preq.get({ uri: server.config.uri + 
'en.wikipedia.org/v1/page/most-read/' + futureDateString,
+                          query: { aggregated: true }})
+          .then(function(res) {
+              assert.status(res, 200);
+              assert.deepEqual(!!res.body, false, 'Expected the body to be 
empty');
+          });
+    });
 });
diff --git a/test/features/news/news.js b/test/features/news/news.js
index 5f4e125..a5eb076 100644
--- a/test/features/news/news.js
+++ b/test/features/news/news.js
@@ -63,6 +63,17 @@
         });
     });
 
+    it('unsupported language with aggregated=true should return 200', 
function() {
+        return preq.get({
+            uri: server.config.uri + 'is.wikipedia.org/v1/page/news',
+            query: { aggregated: true }
+        })
+        .then(function(res) {
+            assert.status(res, 200);
+            assert.deepEqual(!!res.body, false, 'Expected the body to be 
empty');
+        });
+    });
+
     it('URL fragments should be stripped correctly', function() {
         
assert.deepEqual(news.removeFragment('100_metres_hurdles#Top_25_fastest_athletes'),
 '100_metres_hurdles');
         assert.deepEqual(news.removeFragment('Kendra_Harrison'), 
'Kendra_Harrison');

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I453a1f729492a6550661df7bd0e050f04e81f8c0
Gerrit-PatchSet: 4
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: Mholloway <mhollo...@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