diff --git a/src/__mocks__/simple-page.json b/src/__mocks__/simple-page.json index 2f3be28c..da13ab2b 100644 --- a/src/__mocks__/simple-page.json +++ b/src/__mocks__/simple-page.json @@ -10,27 +10,27 @@ "page_uuid": "9420d91c-2fd8-411a-a756-5bf976574d10", "capture_time": "2018-02-01T04:37:15.000Z", "uri": "https://edgi-versionista-archive.s3.amazonaws.com/versionista2/74303-6222064/version-14470996.html", - "version_hash": "15e3e7f86e3f72acd360668b22250b9981f7b3d5f777b3d972557f00cd21153f", + "body_hash": "15e3e7f86e3f72acd360668b22250b9981f7b3d5f777b3d972557f00cd21153f", "media_type": "text/html", "media_type_parameters": "charset=UTF-8", "content_length": 31190, + "headers": { + "age": "0", + "date": "Thu, 01 Feb 2018 05:18:47 GMT", + "vary": "Accept-Encoding", + "expires": "Thu, 01 Feb 2018 05:18:47 GMT", + "x-cachee": "MISS", + "connection": "close", + "content-type": "text/html; charset=UTF-8", + "accept-ranges": "bytes", + "cache-control": "private, max-age=0", + "transfer-encoding": "chunked" + }, "source_type": "versionista", "source_metadata": { "url": "https://versionista.com/74303/6222064/14470996/", "length": 31190, "account": "versionista2", - "headers": { - "age": "0", - "date": "Thu, 01 Feb 2018 05:18:47 GMT", - "vary": "Accept-Encoding", - "expires": "Thu, 01 Feb 2018 05:18:47 GMT", - "x-cachee": "MISS", - "connection": "close", - "content-type": "text/html; charset=UTF-8", - "accept-ranges": "bytes", - "cache-control": "private, max-age=0", - "transfer-encoding": "chunked" - }, "page_id": "6222064", "site_id": "74303", "diff_hash": "28479a7929b2f7f59a8d5837286fd2ecf1a7e6fb267c762dbc0e2bcff352dc1d", @@ -52,7 +52,7 @@ "page_uuid": "9420d91c-2fd8-411a-a756-5bf976574d10", "capture_time": "2017-01-17T13:46:48.000Z", "uri": "https://edgi-versionista-archive.s3.amazonaws.com/versionista2/74303-6222064/version-9437401.html", - "version_hash": "03942355429ebd4bf526199777879fdf069a23ec040a9517b556df8aa4d1a8d3", + "body_hash": "03942355429ebd4bf526199777879fdf069a23ec040a9517b556df8aa4d1a8d3", "media_type": null, "media_type_parameters": null, "content_length": 31190, diff --git a/src/__mocks__/simple-pages.json b/src/__mocks__/simple-pages.json index fdbdcb87..d26bd6b8 100644 --- a/src/__mocks__/simple-pages.json +++ b/src/__mocks__/simple-pages.json @@ -10,27 +10,27 @@ "page_uuid": "553d0acd-8740-47b9-a52e-3e6c15d2846d", "capture_time": "2018-03-04T16:33:33.000Z", "uri": "https://edgi-versionista-archive.s3.amazonaws.com/versionista2/74300-6219628/version-14835175.xml", - "version_hash": "e6f32277c22dece27b719310a65c46f4e21eb3f1c3d13fe82d9cead78bc52186", + "body_hash": "e6f32277c22dece27b719310a65c46f4e21eb3f1c3d13fe82d9cead78bc52186", "media_type": "application/xml", "media_type_parameters": "charset=utf-8", "content_length": 8013, + "headers": { + "age": "0", + "date": "Sun, 04 Mar 2018 17:17:30 GMT", + "vary": "Accept-Encoding", + "expires": "Sun, 04 Mar 2018 17:17:30 GMT", + "x-cachee": "MISS", + "connection": "close", + "content-type": "application/xml; charset=utf-8", + "accept-ranges": "bytes", + "cache-control": "private, max-age=0", + "transfer-encoding": "chunked" + }, "source_type": "versionista", "source_metadata": { "url": "https://versionista.com/74300/6219628/14835175/", "length": 8013, "account": "versionista2", - "headers": { - "age": "0", - "date": "Sun, 04 Mar 2018 17:17:30 GMT", - "vary": "Accept-Encoding", - "expires": "Sun, 04 Mar 2018 17:17:30 GMT", - "x-cachee": "MISS", - "connection": "close", - "content-type": "application/xml; charset=utf-8", - "accept-ranges": "bytes", - "cache-control": "private, max-age=0", - "transfer-encoding": "chunked" - }, "page_id": "6219628", "site_id": "74300", "diff_hash": "8dccfc17403640523feb0339133460df0dd74da8247e115c3a3c27b9f1dd308e", @@ -88,7 +88,7 @@ "page_uuid": "93db6937-3d5d-47b2-bd7c-df49ba716896", "capture_time": "2017-06-19T11:59:22.000Z", "uri": "https://edgi-versionista-archive.s3.amazonaws.com/versionista1/71555-6026676/version-11816086.html", - "version_hash": "10c2283c9e8768980bcc343e7b76a6f51b4dae3632a7f35cd037b8add71b9d0e", + "body_hash": "10c2283c9e8768980bcc343e7b76a6f51b4dae3632a7f35cd037b8add71b9d0e", "media_type": null, "media_type_parameters": null, "content_length": 31190, diff --git a/src/components/diff-view.jsx b/src/components/diff-view.jsx index 1080f703..6aade637 100644 --- a/src/components/diff-view.jsx +++ b/src/components/diff-view.jsx @@ -87,7 +87,7 @@ export default class DiffView extends React.Component { renderNoChangeMessage () { const sameContent = this.props.a && this.props.b - && this.props.a.version_hash === this.props.b.version_hash; + && this.props.a.body_hash === this.props.b.body_hash; const className = 'diff-view__alert'; const styleName = 'alert alert-warning'; diff --git a/src/services/web-monitoring-db.js b/src/services/web-monitoring-db.js index 8ec70f50..08622d64 100644 --- a/src/services/web-monitoring-db.js +++ b/src/services/web-monitoring-db.js @@ -7,8 +7,15 @@ const storageLocation = 'WebMonitoringDb.token'; * @property {string} uuid * @property {string} page_uuid * @property {Date} capture_time - * @property {string} uri - * @property {string} version_hash + * @property {string} url + * @property {string} body_url + * @property {string} body_hash + * @property {number} status + * @property {Object} headers + * @property {number} content_length + * @property {string} media_type + * @property {string} title + * @property {boolean} different * @property {string} source_type * @property {Object} source_metadata * @property {Date} created_at @@ -426,11 +433,31 @@ function parsePage (data) { } function parseVersion (data) { - return Object.assign({}, data, { + const result = Object.assign({}, data, { capture_time: new Date(data.capture_time), created_at: new Date(data.created_at), updated_at: new Date(data.updated_at) }); + + // Update fields that will soon be migrated to new names/locations. + // TODO: delete this section when API is fully migrated. + if (!result.headers && result.source_metadata) { + result.headers = result.source_metadata.headers; + } + if (result.version_hash) { + result.body_hash = result.version_hash; + delete result.version_hash; + } + if (result.uri) { + result.body_url = result.uri; + delete result.uri; + } + if (result.capture_url) { + result.url = result.capture_url; + delete result.capture_url; + } + + return result; } function parseAnnotation (data) {