Niedzielski has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/392076 )

Change subject: Fix: update page summaries for new endpoint responses
......................................................................

Fix: update page summaries for new endpoint responses

The MCS page summary response format appears to have made an API
breaking change by dropping the `thumbnail.original` field. This patch
revises the Marvin implementation.

Change-Id: Ibc0c03d48a08c971c90e6a34d7f96e8af1163421
---
M src/common/marshallers/page-summary/page-summary-expected.test.json
M src/common/marshallers/page-summary/page-summary-restbase.test.json
M src/common/marshallers/page-summary/page-summary-unmarshaller.test.ts
M src/common/marshallers/page-summary/page-summary-unmarshaller.ts
M src/common/marshallers/restbase.ts
M src/common/models/page/image.ts
M src/common/models/page/summary.ts
7 files changed, 10 insertions(+), 60 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/marvin refs/changes/76/392076/1

diff --git 
a/src/common/marshallers/page-summary/page-summary-expected.test.json 
b/src/common/marshallers/page-summary/page-summary-expected.test.json
index b6a741f..4b78760 100644
--- a/src/common/marshallers/page-summary/page-summary-expected.test.json
+++ b/src/common/marshallers/page-summary/page-summary-expected.test.json
@@ -14,8 +14,7 @@
     "url": 
"https://upload.wikimedia.org/wikipedia/commons/thumb/c/c7/Mount-Everest.jpg/320px-Mount-Everest.jpg";,
     "width": 320,
     "height": 213,
-    "landscape": true,
-    "originalURL": 
"http://upload.wikimedia.org/wikipedia/commons/c/c7/Mount-Everest.jpg";
+    "landscape": true
   },
   "image": {
     "url": 
"https://upload.wikimedia.org/wikipedia/commons/c/c7/Mount-Everest.jpg";,
@@ -25,7 +24,7 @@
   },
   "wikiLanguageCode": "en",
   "localeDirection": "ltr",
-  "lastModified": "2017-09-11T16:00:59Z",
+  "lastModified": "2017-11-17T03:58:31Z",
   "descriptionText": "Earth's highest mountain, with a peak at 8,848 metres 
(29,029 feet) above sea level, part of the Himalaya mountain range between 
Nepal and China",
   "geolocation": {
     "latitude": 27.98805556,
diff --git 
a/src/common/marshallers/page-summary/page-summary-restbase.test.json 
b/src/common/marshallers/page-summary/page-summary-restbase.test.json
index 95940a3..d4e3168 100644
--- a/src/common/marshallers/page-summary/page-summary-restbase.test.json
+++ b/src/common/marshallers/page-summary/page-summary-restbase.test.json
@@ -7,8 +7,7 @@
   "thumbnail": {
     "source": 
"https://upload.wikimedia.org/wikipedia/commons/thumb/c/c7/Mount-Everest.jpg/320px-Mount-Everest.jpg";,
     "width": 320,
-    "height": 213,
-    "original": 
"http://upload.wikimedia.org/wikipedia/commons/c/c7/Mount-Everest.jpg";
+    "height": 213
   },
   "originalimage": {
     "source": 
"https://upload.wikimedia.org/wikipedia/commons/c/c7/Mount-Everest.jpg";,
@@ -17,7 +16,7 @@
   },
   "lang": "en",
   "dir": "ltr",
-  "timestamp": "2017-09-11T16:00:59Z",
+  "timestamp": "2017-11-17T03:58:31Z",
   "description": "Earth's highest mountain, with a peak at 8,848 metres 
(29,029 feet) above sea level, part of the Himalaya mountain range between 
Nepal and China",
   "coordinates": {
     "lat": 27.98805556,
diff --git 
a/src/common/marshallers/page-summary/page-summary-unmarshaller.test.ts 
b/src/common/marshallers/page-summary/page-summary-unmarshaller.test.ts
index 091474e..368494e 100644
--- a/src/common/marshallers/page-summary/page-summary-unmarshaller.test.ts
+++ b/src/common/marshallers/page-summary/page-summary-unmarshaller.test.ts
@@ -1,41 +1,16 @@
 import * as assert from "assert";
 import { PageSummary, pageSummaryReviver } from "../../models/page/summary";
-import { PageImage, PageThumbnail } from "../../models/page/image";
+import { PageImage } from "../../models/page/image";
 import { RESTBase } from "../restbase";
 import { EXPECTED_ETAG, HEADERS, reviveFile } from "../utils.test";
 import {
   unmarshalPageImage,
-  unmarshalPageThumbnail,
   unmarshalPageSummary
 } from "./page-summary-unmarshaller";
 
 const NOW = new Date(Date.now()).toString();
 
 describe("page-summary-unmarshaller", () => {
-  describe(".unmarshalPageThumbnail()", () => {
-    [false, true].forEach(landscape => {
-      it(`unmarshals ${landscape ? "landscape" : "portrait"}`, () => {
-        const width = landscape ? 2 : 1;
-        const height = landscape ? 1 : 2;
-        const json: RESTBase.PageSummary.Thumbnail = {
-          source: "source",
-          original: "original",
-          width,
-          height
-        };
-        const expected: PageThumbnail = {
-          url: "source",
-          width,
-          height,
-          landscape,
-          originalURL: "original"
-        };
-        const result = unmarshalPageThumbnail(json as {});
-        assert.deepStrictEqual(result, expected);
-      });
-    });
-  });
-
   describe(".unmarshalPageImage()", () => {
     [false, true].forEach(landscape => {
       it(`unmarshals ${landscape ? "landscape" : "portrait"}`, () => {
diff --git a/src/common/marshallers/page-summary/page-summary-unmarshaller.ts 
b/src/common/marshallers/page-summary/page-summary-unmarshaller.ts
index a1ec020..f0ece26 100644
--- a/src/common/marshallers/page-summary/page-summary-unmarshaller.ts
+++ b/src/common/marshallers/page-summary/page-summary-unmarshaller.ts
@@ -1,4 +1,4 @@
-import { PageImage, PageThumbnail } from "../../models/page/image";
+import { PageImage } from "../../models/page/image";
 import { PageSummary } from "../../models/page/summary";
 import { PageTitleID } from "../../models/page/title";
 import { IsomorphicHeaders } from "../../types/isomorphic-unfetch-extras";
@@ -9,17 +9,6 @@
   unmarshalETag
 } from "../page-base/page-base-unmarshaller";
 import { RESTBase } from "../restbase";
-
-export const unmarshalPageThumbnail = (json: JSONObject): PageThumbnail => {
-  const type: RESTBase.PageSummary.Thumbnail = json as any;
-  return {
-    url: type.source,
-    originalURL: type.original,
-    width: type.width,
-    height: type.height,
-    landscape: type.width > type.height
-  };
-};
 
 export const unmarshalPageImage = (json: JSONObject): PageImage => {
   const type: RESTBase.PageSummary.Image = json as any;
@@ -103,7 +92,7 @@
     result.geolocation = unmarshalPageGeolocation(type.coordinates as {});
   }
   if (type.thumbnail) {
-    result.thumbnail = unmarshalPageThumbnail(type.thumbnail as {});
+    result.thumbnail = unmarshalPageImage(type.thumbnail as {});
   }
   if (type.originalimage) {
     result.image = unmarshalPageImage(type.originalimage as {});
diff --git a/src/common/marshallers/restbase.ts 
b/src/common/marshallers/restbase.ts
index ece8572..1364eb0 100644
--- a/src/common/marshallers/restbase.ts
+++ b/src/common/marshallers/restbase.ts
@@ -24,14 +24,6 @@
     export const ACCEPT_HEADER: string =
       'application/json; charset=utf-8; 
profile="https://www.mediawiki.org/wiki/Specs/Summary/1.2.0";';
 
-    // 
https://phabricator.wikimedia.org/diffusion/GRES/browse/master/v1/summary.yaml;efa0412225221d49e901fdce0ba2ae88cd6ccc11$138
-    export interface Thumbnail {
-      source: string;
-      original: string;
-      width: number;
-      height: number;
-    }
-
     // 
https://phabricator.wikimedia.org/diffusion/GRES/browse/master/v1/summary.yaml;efa0412225221d49e901fdce0ba2ae88cd6ccc11$139
     export interface Image {
       source: string;
@@ -53,7 +45,7 @@
       // 
https://phabricator.wikimedia.org/diffusion/GMOA/browse/master/lib/transformations/summarize.js;a4f603b2f535d8d153b62044a2210acf22bf6e11$58-59
       extract: string;
       extract_html: string; // eslint-disable-line camelcase
-      thumbnail?: Thumbnail;
+      thumbnail?: Image;
       originalimage?: Image;
       lang: string;
       dir: string;
diff --git a/src/common/models/page/image.ts b/src/common/models/page/image.ts
index 7ff93c6..b1b10a8 100644
--- a/src/common/models/page/image.ts
+++ b/src/common/models/page/image.ts
@@ -4,7 +4,3 @@
   height?: number;
   landscape?: boolean;
 }
-
-export interface PageThumbnail extends PageImage {
-  originalURL: string;
-}
diff --git a/src/common/models/page/summary.ts 
b/src/common/models/page/summary.ts
index 1c1023b..5fd7c4b 100644
--- a/src/common/models/page/summary.ts
+++ b/src/common/models/page/summary.ts
@@ -1,12 +1,12 @@
 import { PageBase, pageBaseReviver } from "./page-base";
-import { PageImage, PageThumbnail } from "./image";
+import { PageImage } from "./image";
 
 export interface PageSummary extends PageBase {
   wikiLanguageCode: string;
   localeDirection: string;
   extractText: string;
   extractHTML: string[];
-  thumbnail?: PageThumbnail;
+  thumbnail?: PageImage;
   image?: PageImage;
 }
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibc0c03d48a08c971c90e6a34d7f96e8af1163421
Gerrit-PatchSet: 1
Gerrit-Project: marvin
Gerrit-Branch: master
Gerrit-Owner: Niedzielski <[email protected]>
Gerrit-Reviewer: Sniedzielski <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to