{"action":"created","comment":{"url":"https://api.github.com/repos/guardian/frontend/pulls/comments/24598559","id":24598559,"diff_hunk":"@@ -2,29 +2,29 @@ package model.commercial.books\n \n import common.{AkkaAgent, ExecutionContexts, Logging}\n import conf.Configuration\n-import play.api.Play.current\n+import conf.Switches.GuBookshopFeedsSwitch\n+import model.commercial.{FeedReader, FeedRequest}\n import play.api.libs.json._\n import play.api.libs.oauth.{ConsumerKey, OAuthCalculator, RequestToken}\n-import play.api.libs.ws.WS\n \n import scala.concurrent.Future\n+import scala.concurrent.duration._\n \n object BookFinder extends ExecutionContexts {\n \n   private lazy val agent = AkkaAgent[Map[String, Book]](Map.empty[String, Book])\n \n-  def findByIsbn(isbn: String): Future[Option[Book]] = {\n-    val book = agent.get().get(isbn)\n-    if (book.isDefined) {\n-      Future.successful(book)\n-    } else {\n-      MagentoService.findByIsbn(isbn) map {\n-        _ map { foundBook =>\n-          agent.send { books => books + (isbn -> foundBook)}\n-          foundBook\n-        }\n-      }\n+  def findByIsbn(isbn: String): Option[Book] = {\n+    val maybeBook = agent.get().get(isbn)\n+\n+    if (maybeBook.isEmpty) {","path":"commercial/app/model/commercial/books/BookFinder.scala","position":32,"original_position":32,"commit_id":"175200ccbb7da3398972ef9d8e235172d882c243","original_commit_id":"175200ccbb7da3398972ef9d8e235172d882c243","user":{"login":"gklopper","id":76709,"avatar_url":"https://avatars.githubusercontent.com/u/76709?v=3","gravatar_id":"","url":"https://api.github.com/users/gklopper","html_url":"https://github.com/gklopper","followers_url":"https://api.github.com/users/gklopper/followers","following_url":"https://api.github.com/users/gklopper/following{/other_user}","gists_url":"https://api.github.com/users/gklopper/gists{/gist_id}","starred_url":"https://api.github.com/users/gklopper/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gklopper/subscriptions","organizations_url":"https://api.github.com/users/gklopper/orgs","repos_url":"https://api.github.com/users/gklopper/repos","events_url":"https://api.github.com/users/gklopper/events{/privacy}","received_events_url":"https://api.github.com/users/gklopper/received_events","type":"User","site_admin":false},"body":"And/ Or create a separate execution context for it that naturally throttles it.","created_at":"2015-02-12T17:16:19Z","updated_at":"2015-02-12T17:16:19Z","html_url":"https://github.com/guardian/frontend/pull/8310#discussion_r24598559","pull_request_url":"https://api.github.com/repos/guardian/frontend/pulls/8310","_links":{"self":{"href":"https://api.github.com/repos/guardian/frontend/pulls/comments/24598559"},"html":{"href":"https://github.com/guardian/frontend/pull/8310#discussion_r24598559"},"pull_request":{"href":"https://api.github.com/repos/guardian/frontend/pulls/8310"}}},"pull_request":{"url":"https://api.github.com/repos/guardian/frontend/pulls/8310","id":29193688,"html_url":"https://github.com/guardian/frontend/pull/8310","diff_url":"https://github.com/guardian/frontend/pull/8310.diff","patch_url":"https://github.com/guardian/frontend/pull/8310.patch","issue_url":"https://api.github.com/repos/guardian/frontend/issues/8310","number":8310,"state":"open","locked":false,"title":"Improve Commercial Server Performance","user":{"login":"kelvin-chappell","id":1722550,"avatar_url":"https://avatars.githubusercontent.com/u/1722550?v=3","gravatar_id":"","url":"https://api.github.com/users/kelvin-chappell","html_url":"https://github.com/kelvin-chappell","followers_url":"https://api.github.com/users/kelvin-chappell/followers","following_url":"https://api.github.com/users/kelvin-chappell/following{/other_user}","gists_url":"https://api.github.com/users/kelvin-chappell/gists{/gist_id}","starred_url":"https://api.github.com/users/kelvin-chappell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kelvin-chappell/subscriptions","organizations_url":"https://api.github.com/users/kelvin-chappell/orgs","repos_url":"https://api.github.com/users/kelvin-chappell/repos","events_url":"https://api.github.com/users/kelvin-chappell/events{/privacy}","received_events_url":"https://api.github.com/users/kelvin-chappell/received_events","type":"User","site_admin":false},"body":"By not blocking on book lookup requests.\r\nAnd measuring response time.","created_at":"2015-02-12T16:33:41Z","updated_at":"2015-02-12T17:16:19Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1e8214d15a1b22dcd72d0ea150f32832583e16b9","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/guardian/frontend/pulls/8310/commits","review_comments_url":"https://api.github.com/repos/guardian/frontend/pulls/8310/comments","review_comment_url":"https://api.github.com/repos/guardian/frontend/pulls/comments/{number}","comments_url":"https://api.github.com/repos/guardian/frontend/issues/8310/comments","statuses_url":"https://api.github.com/repos/guardian/frontend/statuses/175200ccbb7da3398972ef9d8e235172d882c243","head":{"label":"guardian:kc-book-lookup","ref":"kc-book-lookup","sha":"175200ccbb7da3398972ef9d8e235172d882c243","user":{"login":"guardian","id":164318,"avatar_url":"https://avatars.githubusercontent.com/u/164318?v=3","gravatar_id":"","url":"https://api.github.com/users/guardian","html_url":"https://github.com/guardian","followers_url":"https://api.github.com/users/guardian/followers","following_url":"https://api.github.com/users/guardian/following{/other_user}","gists_url":"https://api.github.com/users/guardian/gists{/gist_id}","starred_url":"https://api.github.com/users/guardian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guardian/subscriptions","organizations_url":"https://api.github.com/users/guardian/orgs","repos_url":"https://api.github.com/users/guardian/repos","events_url":"https://api.github.com/users/guardian/events{/privacy}","received_events_url":"https://api.github.com/users/guardian/received_events","type":"Organization","site_admin":false},"repo":{"id":4370755,"name":"frontend","full_name":"guardian/frontend","owner":{"login":"guardian","id":164318,"avatar_url":"https://avatars.githubusercontent.com/u/164318?v=3","gravatar_id":"","url":"https://api.github.com/users/guardian","html_url":"https://github.com/guardian","followers_url":"https://api.github.com/users/guardian/followers","following_url":"https://api.github.com/users/guardian/following{/other_user}","gists_url":"https://api.github.com/users/guardian/gists{/gist_id}","starred_url":"https://api.github.com/users/guardian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guardian/subscriptions","organizations_url":"https://api.github.com/users/guardian/orgs","repos_url":"https://api.github.com/users/guardian/repos","events_url":"https://api.github.com/users/guardian/events{/privacy}","received_events_url":"https://api.github.com/users/guardian/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/guardian/frontend","description":"Source for theguardian.com","fork":false,"url":"https://api.github.com/repos/guardian/frontend","forks_url":"https://api.github.com/repos/guardian/frontend/forks","keys_url":"https://api.github.com/repos/guardian/frontend/keys{/key_id}","collaborators_url":"https://api.github.com/repos/guardian/frontend/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/guardian/frontend/teams","hooks_url":"https://api.github.com/repos/guardian/frontend/hooks","issue_events_url":"https://api.github.com/repos/guardian/frontend/issues/events{/number}","events_url":"https://api.github.com/repos/guardian/frontend/events","assignees_url":"https://api.github.com/repos/guardian/frontend/assignees{/user}","branches_url":"https://api.github.com/repos/guardian/frontend/branches{/branch}","tags_url":"https://api.github.com/repos/guardian/frontend/tags","blobs_url":"https://api.github.com/repos/guardian/frontend/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/guardian/frontend/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/guardian/frontend/git/refs{/sha}","trees_url":"https://api.github.com/repos/guardian/frontend/git/trees{/sha}","statuses_url":"https://api.github.com/repos/guardian/frontend/statuses/{sha}","languages_url":"https://api.github.com/repos/guardian/frontend/languages","stargazers_url":"https://api.github.com/repos/guardian/frontend/stargazers","contributors_url":"https://api.github.com/repos/guardian/frontend/contributors","subscribers_url":"https://api.github.com/repos/guardian/frontend/subscribers","subscription_url":"https://api.github.com/repos/guardian/frontend/subscription","commits_url":"https://api.github.com/repos/guardian/frontend/commits{/sha}","git_commits_url":"https://api.github.com/repos/guardian/frontend/git/commits{/sha}","comments_url":"https://api.github.com/repos/guardian/frontend/comments{/number}","issue_comment_url":"https://api.github.com/repos/guardian/frontend/issues/comments/{number}","contents_url":"https://api.github.com/repos/guardian/frontend/contents/{+path}","compare_url":"https://api.github.com/repos/guardian/frontend/compare/{base}...{head}","merges_url":"https://api.github.com/repos/guardian/frontend/merges","archive_url":"https://api.github.com/repos/guardian/frontend/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/guardian/frontend/downloads","issues_url":"https://api.github.com/repos/guardian/frontend/issues{/number}","pulls_url":"https://api.github.com/repos/guardian/frontend/pulls{/number}","milestones_url":"https://api.github.com/repos/guardian/frontend/milestones{/number}","notifications_url":"https://api.github.com/repos/guardian/frontend/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/guardian/frontend/labels{/name}","releases_url":"https://api.github.com/repos/guardian/frontend/releases{/id}","created_at":"2012-05-18T15:39:15Z","updated_at":"2015-02-12T16:54:32Z","pushed_at":"2015-02-12T16:59:45Z","git_url":"git://github.com/guardian/frontend.git","ssh_url":"git@github.com:guardian/frontend.git","clone_url":"https://github.com/guardian/frontend.git","svn_url":"https://github.com/guardian/frontend","homepage":"http://www.theguardian.com","size":513535,"stargazers_count":2661,"watchers_count":2661,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":236,"mirror_url":null,"open_issues_count":216,"forks":236,"open_issues":216,"watchers":2661,"default_branch":"master"}},"base":{"label":"guardian:master","ref":"master","sha":"33f834fac281af59776768f2b3dd75ff638056f8","user":{"login":"guardian","id":164318,"avatar_url":"https://avatars.githubusercontent.com/u/164318?v=3","gravatar_id":"","url":"https://api.github.com/users/guardian","html_url":"https://github.com/guardian","followers_url":"https://api.github.com/users/guardian/followers","following_url":"https://api.github.com/users/guardian/following{/other_user}","gists_url":"https://api.github.com/users/guardian/gists{/gist_id}","starred_url":"https://api.github.com/users/guardian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guardian/subscriptions","organizations_url":"https://api.github.com/users/guardian/orgs","repos_url":"https://api.github.com/users/guardian/repos","events_url":"https://api.github.com/users/guardian/events{/privacy}","received_events_url":"https://api.github.com/users/guardian/received_events","type":"Organization","site_admin":false},"repo":{"id":4370755,"name":"frontend","full_name":"guardian/frontend","owner":{"login":"guardian","id":164318,"avatar_url":"https://avatars.githubusercontent.com/u/164318?v=3","gravatar_id":"","url":"https://api.github.com/users/guardian","html_url":"https://github.com/guardian","followers_url":"https://api.github.com/users/guardian/followers","following_url":"https://api.github.com/users/guardian/following{/other_user}","gists_url":"https://api.github.com/users/guardian/gists{/gist_id}","starred_url":"https://api.github.com/users/guardian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guardian/subscriptions","organizations_url":"https://api.github.com/users/guardian/orgs","repos_url":"https://api.github.com/users/guardian/repos","events_url":"https://api.github.com/users/guardian/events{/privacy}","received_events_url":"https://api.github.com/users/guardian/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/guardian/frontend","description":"Source for theguardian.com","fork":false,"url":"https://api.github.com/repos/guardian/frontend","forks_url":"https://api.github.com/repos/guardian/frontend/forks","keys_url":"https://api.github.com/repos/guardian/frontend/keys{/key_id}","collaborators_url":"https://api.github.com/repos/guardian/frontend/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/guardian/frontend/teams","hooks_url":"https://api.github.com/repos/guardian/frontend/hooks","issue_events_url":"https://api.github.com/repos/guardian/frontend/issues/events{/number}","events_url":"https://api.github.com/repos/guardian/frontend/events","assignees_url":"https://api.github.com/repos/guardian/frontend/assignees{/user}","branches_url":"https://api.github.com/repos/guardian/frontend/branches{/branch}","tags_url":"https://api.github.com/repos/guardian/frontend/tags","blobs_url":"https://api.github.com/repos/guardian/frontend/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/guardian/frontend/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/guardian/frontend/git/refs{/sha}","trees_url":"https://api.github.com/repos/guardian/frontend/git/trees{/sha}","statuses_url":"https://api.github.com/repos/guardian/frontend/statuses/{sha}","languages_url":"https://api.github.com/repos/guardian/frontend/languages","stargazers_url":"https://api.github.com/repos/guardian/frontend/stargazers","contributors_url":"https://api.github.com/repos/guardian/frontend/contributors","subscribers_url":"https://api.github.com/repos/guardian/frontend/subscribers","subscription_url":"https://api.github.com/repos/guardian/frontend/subscription","commits_url":"https://api.github.com/repos/guardian/frontend/commits{/sha}","git_commits_url":"https://api.github.com/repos/guardian/frontend/git/commits{/sha}","comments_url":"https://api.github.com/repos/guardian/frontend/comments{/number}","issue_comment_url":"https://api.github.com/repos/guardian/frontend/issues/comments/{number}","contents_url":"https://api.github.com/repos/guardian/frontend/contents/{+path}","compare_url":"https://api.github.com/repos/guardian/frontend/compare/{base}...{head}","merges_url":"https://api.github.com/repos/guardian/frontend/merges","archive_url":"https://api.github.com/repos/guardian/frontend/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/guardian/frontend/downloads","issues_url":"https://api.github.com/repos/guardian/frontend/issues{/number}","pulls_url":"https://api.github.com/repos/guardian/frontend/pulls{/number}","milestones_url":"https://api.github.com/repos/guardian/frontend/milestones{/number}","notifications_url":"https://api.github.com/repos/guardian/frontend/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/guardian/frontend/labels{/name}","releases_url":"https://api.github.com/repos/guardian/frontend/releases{/id}","created_at":"2012-05-18T15:39:15Z","updated_at":"2015-02-12T16:54:32Z","pushed_at":"2015-02-12T16:59:45Z","git_url":"git://github.com/guardian/frontend.git","ssh_url":"git@github.com:guardian/frontend.git","clone_url":"https://github.com/guardian/frontend.git","svn_url":"https://github.com/guardian/frontend","homepage":"http://www.theguardian.com","size":513535,"stargazers_count":2661,"watchers_count":2661,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":236,"mirror_url":null,"open_issues_count":216,"forks":236,"open_issues":216,"watchers":2661,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/guardian/frontend/pulls/8310"},"html":{"href":"https://github.com/guardian/frontend/pull/8310"},"issue":{"href":"https://api.github.com/repos/guardian/frontend/issues/8310"},"comments":{"href":"https://api.github.com/repos/guardian/frontend/issues/8310/comments"},"review_comments":{"href":"https://api.github.com/repos/guardian/frontend/pulls/8310/comments"},"review_comment":{"href":"https://api.github.com/repos/guardian/frontend/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/guardian/frontend/pulls/8310/commits"},"statuses":{"href":"https://api.github.com/repos/guardian/frontend/statuses/175200ccbb7da3398972ef9d8e235172d882c243"}}}}