{"action":"created","comment":{"url":"https://api.github.com/repos/Financial-Times/next-es-interface/pulls/comments/79833455","id":79833455,"diff_hunk":"@@ -0,0 +1,85 @@\n+const signedFetch = require(`signed-aws-es-fetch`);\n+const CLUSTER = require(`./get-es-cluster`);\n+const logger = require(`@financial-times/n-logger`).default;\n+const logChangedContent = require(`./log-changed-content`);\n+\n+module.exports = function esRequest (event, uuid, verbose = false, modelledContent) {\n+\tconst URL = `https://${CLUSTER}/v3_api_v2/item/${uuid}`;\n+\n+\tconst CONFIG = {\n+\t\tDELETE: {\n+\t\t\tesOpts: { method: `DELETE` },\n+\t\t\tpurgeOpts: { purgeHard: true },\n+\t\t\turl: URL\n+\t\t},\n+\t\tUPDATE: {\n+\t\t\tesOpts: {\n+\t\t\t\tmethod: `POST`,\n+\t\t\t\tbody: JSON.stringify({\n+\t\t\t\t\t_lastUpdatedDateTime: (new Date()).toISOString() // TODO: or _source._lastUpdatedDateTime? see http://next-elastic.ft.com/v3_api_v2/item/11150514-7e78-11e6-8e50-8ec15fb462f4\n+\t\t\t\t})\n+\t\t\t},\n+\t\t\tpurgeOpts: { verbose },\n+\t\t\turl: `${URL}/_update`\n+\t\t},\n+\t\tADD: {\n+\t\t\tesOpts: {\n+\t\t\t\ttimeout: 10000,\n+\t\t\t\tmethod: `PUT`,\n+\t\t\t\theaders: { 'Content-Type': `application/json` },\n+\t\t\t\tbody: JSON.stringify(modelledContent)\n+\t\t\t},\n+\t\t\tpurgeOpts: { verbose },\n+\t\t\turl: URL\n+\t\t}\n+\t};\n+\n+\tconst handleFailure = res => {\n+\t\tlogger.info(`event=${event}_FAILED uuid=${uuid} url=${CONFIG[event].url}`);\n+\n+\t\tif (event !== `DELETE`) {\n+\t\t\treturn res.json();\n+\t\t}\n+\n+\t\t// DELETE failure is a special case (for some reason)\n+\t\treturn res.text().then(err => {\n+\t\t\tthrow new Error(`Search index update failure ${err}`);\n+\t\t});\n+\t};\n+\n+\treturn signedFetch(CONFIG[event].url, CONFIG[event].esOpts)\n+\t\t.then(res => {\n+\t\t\tif (!res.ok) {\n+\t\t\t\treturn handleFailure(res);\n+\t\t\t}\n+\n+\t\t\tconst promises = [\n+\t\t\t\tpurgeCache(uuid, CONFIG[event].purgeOpts),\n+\t\t\t\tlogChangedContent({ event, uuid, url: CONFIG[event].url }, { verbose })\n+\t\t\t];\n+\n+\t\t\treturn Promise.all(promises).then(() => res.json());\n+\t\t});\n+};\n+\n+function purgeCache(id, opts = {}) {","path":"server/lib/es-request.js","position":65,"original_position":65,"commit_id":"bbe02388a2cc309b2e09f27d01aa7d6282abe52a","original_commit_id":"bbe02388a2cc309b2e09f27d01aa7d6282abe52a","user":{"login":"matthew-andrews","id":825088,"avatar_url":"https://avatars.githubusercontent.com/u/825088?v=3","gravatar_id":"","url":"https://api.github.com/users/matthew-andrews","html_url":"https://github.com/matthew-andrews","followers_url":"https://api.github.com/users/matthew-andrews/followers","following_url":"https://api.github.com/users/matthew-andrews/following{/other_user}","gists_url":"https://api.github.com/users/matthew-andrews/gists{/gist_id}","starred_url":"https://api.github.com/users/matthew-andrews/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matthew-andrews/subscriptions","organizations_url":"https://api.github.com/users/matthew-andrews/orgs","repos_url":"https://api.github.com/users/matthew-andrews/repos","events_url":"https://api.github.com/users/matthew-andrews/events{/privacy}","received_events_url":"https://api.github.com/users/matthew-andrews/received_events","type":"User","site_admin":false},"body":"this is to do with fastly rather than es so could make the file smaller by moving it out?","created_at":"2016-09-21T13:33:16Z","updated_at":"2016-09-21T13:33:16Z","html_url":"https://github.com/Financial-Times/next-es-interface/pull/506#discussion_r79833455","pull_request_url":"https://api.github.com/repos/Financial-Times/next-es-interface/pulls/506","_links":{"self":{"href":"https://api.github.com/repos/Financial-Times/next-es-interface/pulls/comments/79833455"},"html":{"href":"https://github.com/Financial-Times/next-es-interface/pull/506#discussion_r79833455"},"pull_request":{"href":"https://api.github.com/repos/Financial-Times/next-es-interface/pulls/506"}}},"pull_request":{"url":"https://api.github.com/repos/Financial-Times/next-es-interface/pulls/506","id":86159993,"html_url":"https://github.com/Financial-Times/next-es-interface/pull/506","diff_url":"https://github.com/Financial-Times/next-es-interface/pull/506.diff","patch_url":"https://github.com/Financial-Times/next-es-interface/pull/506.patch","issue_url":"https://api.github.com/repos/Financial-Times/next-es-interface/issues/506","number":506,"state":"open","locked":false,"title":"Optimise changelog","user":{"login":"TheoLeanse","id":4750238,"avatar_url":"https://avatars.githubusercontent.com/u/4750238?v=3","gravatar_id":"","url":"https://api.github.com/users/TheoLeanse","html_url":"https://github.com/TheoLeanse","followers_url":"https://api.github.com/users/TheoLeanse/followers","following_url":"https://api.github.com/users/TheoLeanse/following{/other_user}","gists_url":"https://api.github.com/users/TheoLeanse/gists{/gist_id}","starred_url":"https://api.github.com/users/TheoLeanse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TheoLeanse/subscriptions","organizations_url":"https://api.github.com/users/TheoLeanse/orgs","repos_url":"https://api.github.com/users/TheoLeanse/repos","events_url":"https://api.github.com/users/TheoLeanse/events{/privacy}","received_events_url":"https://api.github.com/users/TheoLeanse/received_events","type":"User","site_admin":false},"body":"/cc @matthew-andrews \r\n\r\nI think there's quite a lot here... 😁 \r\n\r\n...not least a node 4 vs node 6 issue","created_at":"2016-09-21T13:15:36Z","updated_at":"2016-09-21T13:33:16Z","closed_at":null,"merged_at":null,"merge_commit_sha":"92766d907255682983b8357b9b30f3f54792086c","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/Financial-Times/next-es-interface/pulls/506/commits","review_comments_url":"https://api.github.com/repos/Financial-Times/next-es-interface/pulls/506/comments","review_comment_url":"https://api.github.com/repos/Financial-Times/next-es-interface/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Financial-Times/next-es-interface/issues/506/comments","statuses_url":"https://api.github.com/repos/Financial-Times/next-es-interface/statuses/bbe02388a2cc309b2e09f27d01aa7d6282abe52a","head":{"label":"Financial-Times:theo/optimise-changelog","ref":"theo/optimise-changelog","sha":"bbe02388a2cc309b2e09f27d01aa7d6282abe52a","user":{"login":"Financial-Times","id":3502508,"avatar_url":"https://avatars.githubusercontent.com/u/3502508?v=3","gravatar_id":"","url":"https://api.github.com/users/Financial-Times","html_url":"https://github.com/Financial-Times","followers_url":"https://api.github.com/users/Financial-Times/followers","following_url":"https://api.github.com/users/Financial-Times/following{/other_user}","gists_url":"https://api.github.com/users/Financial-Times/gists{/gist_id}","starred_url":"https://api.github.com/users/Financial-Times/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Financial-Times/subscriptions","organizations_url":"https://api.github.com/users/Financial-Times/orgs","repos_url":"https://api.github.com/users/Financial-Times/repos","events_url":"https://api.github.com/users/Financial-Times/events{/privacy}","received_events_url":"https://api.github.com/users/Financial-Times/received_events","type":"Organization","site_admin":false},"repo":{"id":26874532,"name":"next-es-interface","full_name":"Financial-Times/next-es-interface","owner":{"login":"Financial-Times","id":3502508,"avatar_url":"https://avatars.githubusercontent.com/u/3502508?v=3","gravatar_id":"","url":"https://api.github.com/users/Financial-Times","html_url":"https://github.com/Financial-Times","followers_url":"https://api.github.com/users/Financial-Times/followers","following_url":"https://api.github.com/users/Financial-Times/following{/other_user}","gists_url":"https://api.github.com/users/Financial-Times/gists{/gist_id}","starred_url":"https://api.github.com/users/Financial-Times/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Financial-Times/subscriptions","organizations_url":"https://api.github.com/users/Financial-Times/orgs","repos_url":"https://api.github.com/users/Financial-Times/repos","events_url":"https://api.github.com/users/Financial-Times/events{/privacy}","received_events_url":"https://api.github.com/users/Financial-Times/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Financial-Times/next-es-interface","description":"Babysits Next's ElasticSearch clusters","fork":false,"url":"https://api.github.com/repos/Financial-Times/next-es-interface","forks_url":"https://api.github.com/repos/Financial-Times/next-es-interface/forks","keys_url":"https://api.github.com/repos/Financial-Times/next-es-interface/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Financial-Times/next-es-interface/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Financial-Times/next-es-interface/teams","hooks_url":"https://api.github.com/repos/Financial-Times/next-es-interface/hooks","issue_events_url":"https://api.github.com/repos/Financial-Times/next-es-interface/issues/events{/number}","events_url":"https://api.github.com/repos/Financial-Times/next-es-interface/events","assignees_url":"https://api.github.com/repos/Financial-Times/next-es-interface/assignees{/user}","branches_url":"https://api.github.com/repos/Financial-Times/next-es-interface/branches{/branch}","tags_url":"https://api.github.com/repos/Financial-Times/next-es-interface/tags","blobs_url":"https://api.github.com/repos/Financial-Times/next-es-interface/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Financial-Times/next-es-interface/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Financial-Times/next-es-interface/git/refs{/sha}","trees_url":"https://api.github.com/repos/Financial-Times/next-es-interface/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Financial-Times/next-es-interface/statuses/{sha}","languages_url":"https://api.github.com/repos/Financial-Times/next-es-interface/languages","stargazers_url":"https://api.github.com/repos/Financial-Times/next-es-interface/stargazers","contributors_url":"https://api.github.com/repos/Financial-Times/next-es-interface/contributors","subscribers_url":"https://api.github.com/repos/Financial-Times/next-es-interface/subscribers","subscription_url":"https://api.github.com/repos/Financial-Times/next-es-interface/subscription","commits_url":"https://api.github.com/repos/Financial-Times/next-es-interface/commits{/sha}","git_commits_url":"https://api.github.com/repos/Financial-Times/next-es-interface/git/commits{/sha}","comments_url":"https://api.github.com/repos/Financial-Times/next-es-interface/comments{/number}","issue_comment_url":"https://api.github.com/repos/Financial-Times/next-es-interface/issues/comments{/number}","contents_url":"https://api.github.com/repos/Financial-Times/next-es-interface/contents/{+path}","compare_url":"https://api.github.com/repos/Financial-Times/next-es-interface/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Financial-Times/next-es-interface/merges","archive_url":"https://api.github.com/repos/Financial-Times/next-es-interface/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Financial-Times/next-es-interface/downloads","issues_url":"https://api.github.com/repos/Financial-Times/next-es-interface/issues{/number}","pulls_url":"https://api.github.com/repos/Financial-Times/next-es-interface/pulls{/number}","milestones_url":"https://api.github.com/repos/Financial-Times/next-es-interface/milestones{/number}","notifications_url":"https://api.github.com/repos/Financial-Times/next-es-interface/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Financial-Times/next-es-interface/labels{/name}","releases_url":"https://api.github.com/repos/Financial-Times/next-es-interface/releases{/id}","deployments_url":"https://api.github.com/repos/Financial-Times/next-es-interface/deployments","created_at":"2014-11-19T18:09:48Z","updated_at":"2016-08-04T12:38:12Z","pushed_at":"2016-09-21T13:29:43Z","git_url":"git://github.com/Financial-Times/next-es-interface.git","ssh_url":"git@github.com:Financial-Times/next-es-interface.git","clone_url":"https://github.com/Financial-Times/next-es-interface.git","svn_url":"https://github.com/Financial-Times/next-es-interface","homepage":"","size":22163,"stargazers_count":1,"watchers_count":1,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":24,"forks":0,"open_issues":24,"watchers":1,"default_branch":"master"}},"base":{"label":"Financial-Times:master","ref":"master","sha":"9d10e0d76018eeee5a959b1ee444c51008fedd89","user":{"login":"Financial-Times","id":3502508,"avatar_url":"https://avatars.githubusercontent.com/u/3502508?v=3","gravatar_id":"","url":"https://api.github.com/users/Financial-Times","html_url":"https://github.com/Financial-Times","followers_url":"https://api.github.com/users/Financial-Times/followers","following_url":"https://api.github.com/users/Financial-Times/following{/other_user}","gists_url":"https://api.github.com/users/Financial-Times/gists{/gist_id}","starred_url":"https://api.github.com/users/Financial-Times/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Financial-Times/subscriptions","organizations_url":"https://api.github.com/users/Financial-Times/orgs","repos_url":"https://api.github.com/users/Financial-Times/repos","events_url":"https://api.github.com/users/Financial-Times/events{/privacy}","received_events_url":"https://api.github.com/users/Financial-Times/received_events","type":"Organization","site_admin":false},"repo":{"id":26874532,"name":"next-es-interface","full_name":"Financial-Times/next-es-interface","owner":{"login":"Financial-Times","id":3502508,"avatar_url":"https://avatars.githubusercontent.com/u/3502508?v=3","gravatar_id":"","url":"https://api.github.com/users/Financial-Times","html_url":"https://github.com/Financial-Times","followers_url":"https://api.github.com/users/Financial-Times/followers","following_url":"https://api.github.com/users/Financial-Times/following{/other_user}","gists_url":"https://api.github.com/users/Financial-Times/gists{/gist_id}","starred_url":"https://api.github.com/users/Financial-Times/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Financial-Times/subscriptions","organizations_url":"https://api.github.com/users/Financial-Times/orgs","repos_url":"https://api.github.com/users/Financial-Times/repos","events_url":"https://api.github.com/users/Financial-Times/events{/privacy}","received_events_url":"https://api.github.com/users/Financial-Times/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Financial-Times/next-es-interface","description":"Babysits Next's ElasticSearch clusters","fork":false,"url":"https://api.github.com/repos/Financial-Times/next-es-interface","forks_url":"https://api.github.com/repos/Financial-Times/next-es-interface/forks","keys_url":"https://api.github.com/repos/Financial-Times/next-es-interface/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Financial-Times/next-es-interface/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Financial-Times/next-es-interface/teams","hooks_url":"https://api.github.com/repos/Financial-Times/next-es-interface/hooks","issue_events_url":"https://api.github.com/repos/Financial-Times/next-es-interface/issues/events{/number}","events_url":"https://api.github.com/repos/Financial-Times/next-es-interface/events","assignees_url":"https://api.github.com/repos/Financial-Times/next-es-interface/assignees{/user}","branches_url":"https://api.github.com/repos/Financial-Times/next-es-interface/branches{/branch}","tags_url":"https://api.github.com/repos/Financial-Times/next-es-interface/tags","blobs_url":"https://api.github.com/repos/Financial-Times/next-es-interface/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Financial-Times/next-es-interface/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Financial-Times/next-es-interface/git/refs{/sha}","trees_url":"https://api.github.com/repos/Financial-Times/next-es-interface/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Financial-Times/next-es-interface/statuses/{sha}","languages_url":"https://api.github.com/repos/Financial-Times/next-es-interface/languages","stargazers_url":"https://api.github.com/repos/Financial-Times/next-es-interface/stargazers","contributors_url":"https://api.github.com/repos/Financial-Times/next-es-interface/contributors","subscribers_url":"https://api.github.com/repos/Financial-Times/next-es-interface/subscribers","subscription_url":"https://api.github.com/repos/Financial-Times/next-es-interface/subscription","commits_url":"https://api.github.com/repos/Financial-Times/next-es-interface/commits{/sha}","git_commits_url":"https://api.github.com/repos/Financial-Times/next-es-interface/git/commits{/sha}","comments_url":"https://api.github.com/repos/Financial-Times/next-es-interface/comments{/number}","issue_comment_url":"https://api.github.com/repos/Financial-Times/next-es-interface/issues/comments{/number}","contents_url":"https://api.github.com/repos/Financial-Times/next-es-interface/contents/{+path}","compare_url":"https://api.github.com/repos/Financial-Times/next-es-interface/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Financial-Times/next-es-interface/merges","archive_url":"https://api.github.com/repos/Financial-Times/next-es-interface/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Financial-Times/next-es-interface/downloads","issues_url":"https://api.github.com/repos/Financial-Times/next-es-interface/issues{/number}","pulls_url":"https://api.github.com/repos/Financial-Times/next-es-interface/pulls{/number}","milestones_url":"https://api.github.com/repos/Financial-Times/next-es-interface/milestones{/number}","notifications_url":"https://api.github.com/repos/Financial-Times/next-es-interface/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Financial-Times/next-es-interface/labels{/name}","releases_url":"https://api.github.com/repos/Financial-Times/next-es-interface/releases{/id}","deployments_url":"https://api.github.com/repos/Financial-Times/next-es-interface/deployments","created_at":"2014-11-19T18:09:48Z","updated_at":"2016-08-04T12:38:12Z","pushed_at":"2016-09-21T13:29:43Z","git_url":"git://github.com/Financial-Times/next-es-interface.git","ssh_url":"git@github.com:Financial-Times/next-es-interface.git","clone_url":"https://github.com/Financial-Times/next-es-interface.git","svn_url":"https://github.com/Financial-Times/next-es-interface","homepage":"","size":22163,"stargazers_count":1,"watchers_count":1,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":24,"forks":0,"open_issues":24,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Financial-Times/next-es-interface/pulls/506"},"html":{"href":"https://github.com/Financial-Times/next-es-interface/pull/506"},"issue":{"href":"https://api.github.com/repos/Financial-Times/next-es-interface/issues/506"},"comments":{"href":"https://api.github.com/repos/Financial-Times/next-es-interface/issues/506/comments"},"review_comments":{"href":"https://api.github.com/repos/Financial-Times/next-es-interface/pulls/506/comments"},"review_comment":{"href":"https://api.github.com/repos/Financial-Times/next-es-interface/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Financial-Times/next-es-interface/pulls/506/commits"},"statuses":{"href":"https://api.github.com/repos/Financial-Times/next-es-interface/statuses/bbe02388a2cc309b2e09f27d01aa7d6282abe52a"}}}}
{"actor":{"display_login":"matthew-andrews"}}