{"action":"created","comment":{"url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/pulls/comments/196492492","pull_request_review_id":130055225,"id":196492492,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5NjQ5MjQ5Mg==","diff_hunk":"@@ -0,0 +1,123 @@\n+const FactFinderClient = require('./factfinder/Client')\n+const factFinderClientFactoryMapper = require('./shopgate/factFinderClientFactoryMapper')\n+const { decorateError, decorateErrorWithParams, decorateDebug } = require('./shopgate/logDecorator')\n+const ShopgateProductSearchSort = require('./shopgate/product/search/sort')\n+const { createHash } = require('crypto')\n+\n+const FOLLOW_SEARCH_KEY = 'followSearch'\n+\n+/**\n+ * @param {PipelineContext} context\n+ * @param {productsSearchInput} input\n+ * @returns {Promise<Object>}\n+ */\n+module.exports = async function (context, input) {\n+  if (!input.searchPhrase) {\n+    return {\n+      searchProductCount: 0,\n+      searchProductIds: []\n+    }\n+  }\n+\n+  /**\n+   * @type {FactFinderClient}\n+   */\n+  const factFinderClient = factFinderClientFactoryMapper(context.config)\n+\n+  try {\n+    const searchHash = createHash('md5').update(input.searchPhrase).digest('hex')\n+\n+    const searchRequest = FactFinderClient.searchRequestBuilder()\n+      .channel(context.config.channel)\n+      .query(input.searchPhrase)\n+      .surpressCampaigns()\n+\n+    // sorting\n+    if (input.sort) {\n+      let shopgateSort = ShopgateProductSearchSort.create(input.sort)\n+      if (shopgateSort === null) {\n+        shopgateSort = ShopgateProductSearchSort.random\n+      }\n+\n+      const { fieldName, direction } = getFactFinderSortFieldNameAndDirection(shopgateSort)\n+      if (direction === null) {\n+        searchRequest.sortByRelevance()\n+      } else {\n+        searchRequest.sortBy(fieldName, direction)\n+      }\n+    }\n+\n+    // filters\n+    if (input.filters) {\n+      Object.keys(input.filters).forEach(filter => {\n+        const shopgatefilter = input.filters[filter]\n+        // atm we support only multi select\n+        searchRequest.addFilter(filter, FactFinderClient.groups.filterStyle.MULTISELECT, shopgatefilter.values)\n+      })\n+    }\n+\n+    // pagination - limit and offset are optional\n+    if (input.limit && input.offset) {\n+      searchRequest.productsPerPage(input.limit)\n+      searchRequest.page(1 + Math.floor(input.offset / input.limit))\n+    }\n+\n+    const followSearch = await context.storage.device.get(getFollowSearchKey(searchHash))\n+    if (followSearch) {\n+      context.log.debug(decorateDebug(getCollectables(context, input, { followSearch })), 'Following search')\n+      searchRequest.followSearch(followSearch)\n+    }\n+\n+    const searchResults = await factFinderClient.search(searchRequest.build(), context.config.uidTemplate)\n+\n+    // store the followSearch parameter\n+    context.storage.device.set(getFollowSearchKey(searchHash), searchResults.followSearch)","path":"extension/lib/getProducts.search.js","position":74,"original_position":74,"commit_id":"7d356dd8c4b1b324606019add7ac8906e9e89a42","original_commit_id":"7d356dd8c4b1b324606019add7ac8906e9e89a42","user":{"login":"chrisEff","id":5214772,"node_id":"MDQ6VXNlcjUyMTQ3NzI=","avatar_url":"https://avatars3.githubusercontent.com/u/5214772?v=4","gravatar_id":"","url":"https://api.github.com/users/chrisEff","html_url":"https://github.com/chrisEff","followers_url":"https://api.github.com/users/chrisEff/followers","following_url":"https://api.github.com/users/chrisEff/following{/other_user}","gists_url":"https://api.github.com/users/chrisEff/gists{/gist_id}","starred_url":"https://api.github.com/users/chrisEff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chrisEff/subscriptions","organizations_url":"https://api.github.com/users/chrisEff/orgs","repos_url":"https://api.github.com/users/chrisEff/repos","events_url":"https://api.github.com/users/chrisEff/events{/privacy}","received_events_url":"https://api.github.com/users/chrisEff/received_events","type":"User","site_admin":false},"body":"I think we should await this and handle the error with a regular try/catch","created_at":"2018-06-19T16:22:26Z","updated_at":"2018-06-19T16:22:26Z","html_url":"https://github.com/shopgate/ext-search-fact-finder/pull/13#discussion_r196492492","pull_request_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/pulls/13","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/shopgate/ext-search-fact-finder/pulls/comments/196492492"},"html":{"href":"https://github.com/shopgate/ext-search-fact-finder/pull/13#discussion_r196492492"},"pull_request":{"href":"https://api.github.com/repos/shopgate/ext-search-fact-finder/pulls/13"}}},"pull_request":{"url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/pulls/13","id":195731616,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk1NzMxNjE2","html_url":"https://github.com/shopgate/ext-search-fact-finder/pull/13","diff_url":"https://github.com/shopgate/ext-search-fact-finder/pull/13.diff","patch_url":"https://github.com/shopgate/ext-search-fact-finder/pull/13.patch","issue_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/issues/13","number":13,"state":"open","locked":false,"title":"Ccp 586 get products","user":{"login":"sofib","id":8367947,"node_id":"MDQ6VXNlcjgzNjc5NDc=","avatar_url":"https://avatars3.githubusercontent.com/u/8367947?v=4","gravatar_id":"","url":"https://api.github.com/users/sofib","html_url":"https://github.com/sofib","followers_url":"https://api.github.com/users/sofib/followers","following_url":"https://api.github.com/users/sofib/following{/other_user}","gists_url":"https://api.github.com/users/sofib/gists{/gist_id}","starred_url":"https://api.github.com/users/sofib/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sofib/subscriptions","organizations_url":"https://api.github.com/users/sofib/orgs","repos_url":"https://api.github.com/users/sofib/repos","events_url":"https://api.github.com/users/sofib/events{/privacy}","received_events_url":"https://api.github.com/users/sofib/received_events","type":"User","site_admin":false},"body":"Working implementation for get products, contains fixes for filters and more parameters to the fact-finder search itself.","created_at":"2018-06-19T07:15:07Z","updated_at":"2018-06-19T16:22:26Z","closed_at":null,"merged_at":null,"merge_commit_sha":"228c70854408c58aadcdb1d5d26ce06e40e4677e","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/pulls/13/commits","review_comments_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/pulls/13/comments","review_comment_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/pulls/comments{/number}","comments_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/issues/13/comments","statuses_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/statuses/7d356dd8c4b1b324606019add7ac8906e9e89a42","head":{"label":"shopgate:CCP-586-get-products","ref":"CCP-586-get-products","sha":"7d356dd8c4b1b324606019add7ac8906e9e89a42","user":{"login":"shopgate","id":7113393,"node_id":"MDEyOk9yZ2FuaXphdGlvbjcxMTMzOTM=","avatar_url":"https://avatars3.githubusercontent.com/u/7113393?v=4","gravatar_id":"","url":"https://api.github.com/users/shopgate","html_url":"https://github.com/shopgate","followers_url":"https://api.github.com/users/shopgate/followers","following_url":"https://api.github.com/users/shopgate/following{/other_user}","gists_url":"https://api.github.com/users/shopgate/gists{/gist_id}","starred_url":"https://api.github.com/users/shopgate/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shopgate/subscriptions","organizations_url":"https://api.github.com/users/shopgate/orgs","repos_url":"https://api.github.com/users/shopgate/repos","events_url":"https://api.github.com/users/shopgate/events{/privacy}","received_events_url":"https://api.github.com/users/shopgate/received_events","type":"Organization","site_admin":false},"repo":{"id":134850249,"node_id":"MDEwOlJlcG9zaXRvcnkxMzQ4NTAyNDk=","name":"ext-search-fact-finder","full_name":"shopgate/ext-search-fact-finder","owner":{"login":"shopgate","id":7113393,"node_id":"MDEyOk9yZ2FuaXphdGlvbjcxMTMzOTM=","avatar_url":"https://avatars3.githubusercontent.com/u/7113393?v=4","gravatar_id":"","url":"https://api.github.com/users/shopgate","html_url":"https://github.com/shopgate","followers_url":"https://api.github.com/users/shopgate/followers","following_url":"https://api.github.com/users/shopgate/following{/other_user}","gists_url":"https://api.github.com/users/shopgate/gists{/gist_id}","starred_url":"https://api.github.com/users/shopgate/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shopgate/subscriptions","organizations_url":"https://api.github.com/users/shopgate/orgs","repos_url":"https://api.github.com/users/shopgate/repos","events_url":"https://api.github.com/users/shopgate/events{/privacy}","received_events_url":"https://api.github.com/users/shopgate/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/shopgate/ext-search-fact-finder","description":"FACT-finder search integration for Shopgate Connect, see https://www.fact-finder.de/","fork":false,"url":"https://api.github.com/repos/shopgate/ext-search-fact-finder","forks_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/forks","keys_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/keys{/key_id}","collaborators_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/teams","hooks_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/hooks","issue_events_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/issues/events{/number}","events_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/events","assignees_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/assignees{/user}","branches_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/branches{/branch}","tags_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/tags","blobs_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/git/refs{/sha}","trees_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/git/trees{/sha}","statuses_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/statuses/{sha}","languages_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/languages","stargazers_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/stargazers","contributors_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/contributors","subscribers_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/subscribers","subscription_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/subscription","commits_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/commits{/sha}","git_commits_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/git/commits{/sha}","comments_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/comments{/number}","issue_comment_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/issues/comments{/number}","contents_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/contents/{+path}","compare_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/compare/{base}...{head}","merges_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/merges","archive_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/downloads","issues_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/issues{/number}","pulls_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/pulls{/number}","milestones_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/milestones{/number}","notifications_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/labels{/name}","releases_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/releases{/id}","deployments_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/deployments","created_at":"2018-05-25T11:59:26Z","updated_at":"2018-05-28T08:04:55Z","pushed_at":"2018-06-19T07:15:07Z","git_url":"git://github.com/shopgate/ext-search-fact-finder.git","ssh_url":"git@github.com:shopgate/ext-search-fact-finder.git","clone_url":"https://github.com/shopgate/ext-search-fact-finder.git","svn_url":"https://github.com/shopgate/ext-search-fact-finder","homepage":null,"size":89,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":2,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"base":{"label":"shopgate:CCP-439-search-story","ref":"CCP-439-search-story","sha":"73bec2928e9dc3d39d01825001174fbc35608ee1","user":{"login":"shopgate","id":7113393,"node_id":"MDEyOk9yZ2FuaXphdGlvbjcxMTMzOTM=","avatar_url":"https://avatars3.githubusercontent.com/u/7113393?v=4","gravatar_id":"","url":"https://api.github.com/users/shopgate","html_url":"https://github.com/shopgate","followers_url":"https://api.github.com/users/shopgate/followers","following_url":"https://api.github.com/users/shopgate/following{/other_user}","gists_url":"https://api.github.com/users/shopgate/gists{/gist_id}","starred_url":"https://api.github.com/users/shopgate/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shopgate/subscriptions","organizations_url":"https://api.github.com/users/shopgate/orgs","repos_url":"https://api.github.com/users/shopgate/repos","events_url":"https://api.github.com/users/shopgate/events{/privacy}","received_events_url":"https://api.github.com/users/shopgate/received_events","type":"Organization","site_admin":false},"repo":{"id":134850249,"node_id":"MDEwOlJlcG9zaXRvcnkxMzQ4NTAyNDk=","name":"ext-search-fact-finder","full_name":"shopgate/ext-search-fact-finder","owner":{"login":"shopgate","id":7113393,"node_id":"MDEyOk9yZ2FuaXphdGlvbjcxMTMzOTM=","avatar_url":"https://avatars3.githubusercontent.com/u/7113393?v=4","gravatar_id":"","url":"https://api.github.com/users/shopgate","html_url":"https://github.com/shopgate","followers_url":"https://api.github.com/users/shopgate/followers","following_url":"https://api.github.com/users/shopgate/following{/other_user}","gists_url":"https://api.github.com/users/shopgate/gists{/gist_id}","starred_url":"https://api.github.com/users/shopgate/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shopgate/subscriptions","organizations_url":"https://api.github.com/users/shopgate/orgs","repos_url":"https://api.github.com/users/shopgate/repos","events_url":"https://api.github.com/users/shopgate/events{/privacy}","received_events_url":"https://api.github.com/users/shopgate/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/shopgate/ext-search-fact-finder","description":"FACT-finder search integration for Shopgate Connect, see https://www.fact-finder.de/","fork":false,"url":"https://api.github.com/repos/shopgate/ext-search-fact-finder","forks_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/forks","keys_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/keys{/key_id}","collaborators_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/teams","hooks_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/hooks","issue_events_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/issues/events{/number}","events_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/events","assignees_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/assignees{/user}","branches_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/branches{/branch}","tags_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/tags","blobs_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/git/refs{/sha}","trees_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/git/trees{/sha}","statuses_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/statuses/{sha}","languages_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/languages","stargazers_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/stargazers","contributors_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/contributors","subscribers_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/subscribers","subscription_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/subscription","commits_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/commits{/sha}","git_commits_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/git/commits{/sha}","comments_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/comments{/number}","issue_comment_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/issues/comments{/number}","contents_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/contents/{+path}","compare_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/compare/{base}...{head}","merges_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/merges","archive_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/downloads","issues_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/issues{/number}","pulls_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/pulls{/number}","milestones_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/milestones{/number}","notifications_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/labels{/name}","releases_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/releases{/id}","deployments_url":"https://api.github.com/repos/shopgate/ext-search-fact-finder/deployments","created_at":"2018-05-25T11:59:26Z","updated_at":"2018-05-28T08:04:55Z","pushed_at":"2018-06-19T07:15:07Z","git_url":"git://github.com/shopgate/ext-search-fact-finder.git","ssh_url":"git@github.com:shopgate/ext-search-fact-finder.git","clone_url":"https://github.com/shopgate/ext-search-fact-finder.git","svn_url":"https://github.com/shopgate/ext-search-fact-finder","homepage":null,"size":89,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":2,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/shopgate/ext-search-fact-finder/pulls/13"},"html":{"href":"https://github.com/shopgate/ext-search-fact-finder/pull/13"},"issue":{"href":"https://api.github.com/repos/shopgate/ext-search-fact-finder/issues/13"},"comments":{"href":"https://api.github.com/repos/shopgate/ext-search-fact-finder/issues/13/comments"},"review_comments":{"href":"https://api.github.com/repos/shopgate/ext-search-fact-finder/pulls/13/comments"},"review_comment":{"href":"https://api.github.com/repos/shopgate/ext-search-fact-finder/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/shopgate/ext-search-fact-finder/pulls/13/commits"},"statuses":{"href":"https://api.github.com/repos/shopgate/ext-search-fact-finder/statuses/7d356dd8c4b1b324606019add7ac8906e9e89a42"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"chrisEff"}}