{"action":"created","comment":{"url":"https://api.github.com/repos/hejare/aws-motioner-data/pulls/comments/232189919","pull_request_review_id":173332012,"id":232189919,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzMjE4OTkxOQ==","diff_hunk":"@@ -73,146 +71,195 @@ async function parseQueryResult(data) {\n     } catch (error) {\n       errorHelper.logError(\"Could not fetch status for url \" + statusUrl +\n         \"\\n Reason: \" + error);\n+      errorHelper.logIncomplete(dok.dok_id);\n       statusInfo.isPending = true;\n     }\n \n     let toAdd = {};\n     Object.assign(toAdd, basicInfo, statusInfo);\n-    const toAddSize = sizeof(toAdd);\n-    const maxSize = process.env.DB_ITEM_MAX_SIZE;\n     toAddItems.push({\n       index: {\n         _index: WDIP_MOTION_INDEX,\n         _type: \"_doc\",\n         _id: basicInfo.dok_id\n       }\n     });\n-    if (maxSize && toAddSize > maxSize) {\n-      logger.warn(`Stripping very large object with id ${toAdd.dok_id} and size ${toAddSize}.`);\n-      let strippedObj = docHelpers.parseBasicInfo(dok);\n-      strippedObj.isPending = toAdd.isPending;\n-      strippedObj.status = toAdd.status;\n-      logger.debug(`New size: ${sizeof(strippedObj)}`);\n-      toAddItems.push(strippedObj);\n-    } else {\n-      toAddItems.push(toAdd);\n-    }\n+    toAddItems.push(toAdd);\n   }\n \n   //Each document consists of two entries, action description and the data itself.\n   const nItems = toAddItems.length / 2;\n \n   if (nItems > 0) {\n-    logger.debug(`Writing ${nItems} items to DB.\"`);\n+    logger.debug(`Writing ${nItems} items to DB.`);\n     try {\n-      return dbClient.bulk({\n-        body: toAddItems\n-      });\n-    } catch (error) {\n-      errorHelper.logError(\"Error when adding documents to index: \" + \": \" + err);\n+      const { items } = await dbClient.bulk({body: toAddItems });\n+      let nAdded = 0;\n+      for (const item of items) {\n+        if (item.index.status === 200 || item.index.status === 201) {\n+          ++nAdded;\n+        } else {\n+          errorHelper.logIncomplete(item.index._id);\n+        }\n+      }\n+      return nAdded;\n+    } catch (err) {\n+      for (let i = 1; i < toAddItems.length; i += 2) {\n+        errorHelper.logIncomplete(item.dok_id);","path":"wdip-be/src/scheduledJobs/fetchMotions.js","position":121,"original_position":121,"commit_id":"86fa583bf41a0cb931ab6980b477fe47929f406b","original_commit_id":"86fa583bf41a0cb931ab6980b477fe47929f406b","user":{"login":"yvonnele","id":2657079,"node_id":"MDQ6VXNlcjI2NTcwNzk=","avatar_url":"https://avatars2.githubusercontent.com/u/2657079?v=4","gravatar_id":"","url":"https://api.github.com/users/yvonnele","html_url":"https://github.com/yvonnele","followers_url":"https://api.github.com/users/yvonnele/followers","following_url":"https://api.github.com/users/yvonnele/following{/other_user}","gists_url":"https://api.github.com/users/yvonnele/gists{/gist_id}","starred_url":"https://api.github.com/users/yvonnele/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yvonnele/subscriptions","organizations_url":"https://api.github.com/users/yvonnele/orgs","repos_url":"https://api.github.com/users/yvonnele/repos","events_url":"https://api.github.com/users/yvonnele/events{/privacy}","received_events_url":"https://api.github.com/users/yvonnele/received_events","type":"User","site_admin":false},"body":"I don't think item is accessible or changes in the for-loop. Did you mean toAddItems[i] or something similar? ","created_at":"2018-11-09T09:33:59Z","updated_at":"2018-11-09T09:33:59Z","html_url":"https://github.com/hejare/aws-motioner-data/pull/44#discussion_r232189919","pull_request_url":"https://api.github.com/repos/hejare/aws-motioner-data/pulls/44","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/hejare/aws-motioner-data/pulls/comments/232189919"},"html":{"href":"https://github.com/hejare/aws-motioner-data/pull/44#discussion_r232189919"},"pull_request":{"href":"https://api.github.com/repos/hejare/aws-motioner-data/pulls/44"}}},"pull_request":{"url":"https://api.github.com/repos/hejare/aws-motioner-data/pulls/44","id":229517213,"node_id":"MDExOlB1bGxSZXF1ZXN0MjI5NTE3MjEz","html_url":"https://github.com/hejare/aws-motioner-data/pull/44","diff_url":"https://github.com/hejare/aws-motioner-data/pull/44.diff","patch_url":"https://github.com/hejare/aws-motioner-data/pull/44.patch","issue_url":"https://api.github.com/repos/hejare/aws-motioner-data/issues/44","number":44,"state":"open","locked":false,"title":"Batch fetch","user":{"login":"markushont","id":17526296,"node_id":"MDQ6VXNlcjE3NTI2Mjk2","avatar_url":"https://avatars0.githubusercontent.com/u/17526296?v=4","gravatar_id":"","url":"https://api.github.com/users/markushont","html_url":"https://github.com/markushont","followers_url":"https://api.github.com/users/markushont/followers","following_url":"https://api.github.com/users/markushont/following{/other_user}","gists_url":"https://api.github.com/users/markushont/gists{/gist_id}","starred_url":"https://api.github.com/users/markushont/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markushont/subscriptions","organizations_url":"https://api.github.com/users/markushont/orgs","repos_url":"https://api.github.com/users/markushont/repos","events_url":"https://api.github.com/users/markushont/events{/privacy}","received_events_url":"https://api.github.com/users/markushont/received_events","type":"User","site_admin":false},"body":"Enable fetching motions in larger batches. Some big changes and too few commits, might be a little messy to review, sorry! I'm happy to explain myself if you're not following what's going on :)\r\n\r\nThis change significantly slows down the job since I removed some of the parallelism. But that might be good so we don't flood the Riksdagen API until they refuse to respond. Will revisit and see if we can improve performance slightly anyway.","created_at":"2018-11-08T21:39:34Z","updated_at":"2018-11-09T09:33:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"82594a6c8a59e6ad5bb01c789a2e75ce5cf527ce","assignee":null,"assignees":[],"requested_reviewers":[{"login":"henriksvensson","id":1612710,"node_id":"MDQ6VXNlcjE2MTI3MTA=","avatar_url":"https://avatars1.githubusercontent.com/u/1612710?v=4","gravatar_id":"","url":"https://api.github.com/users/henriksvensson","html_url":"https://github.com/henriksvensson","followers_url":"https://api.github.com/users/henriksvensson/followers","following_url":"https://api.github.com/users/henriksvensson/following{/other_user}","gists_url":"https://api.github.com/users/henriksvensson/gists{/gist_id}","starred_url":"https://api.github.com/users/henriksvensson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/henriksvensson/subscriptions","organizations_url":"https://api.github.com/users/henriksvensson/orgs","repos_url":"https://api.github.com/users/henriksvensson/repos","events_url":"https://api.github.com/users/henriksvensson/events{/privacy}","received_events_url":"https://api.github.com/users/henriksvensson/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/hejare/aws-motioner-data/pulls/44/commits","review_comments_url":"https://api.github.com/repos/hejare/aws-motioner-data/pulls/44/comments","review_comment_url":"https://api.github.com/repos/hejare/aws-motioner-data/pulls/comments{/number}","comments_url":"https://api.github.com/repos/hejare/aws-motioner-data/issues/44/comments","statuses_url":"https://api.github.com/repos/hejare/aws-motioner-data/statuses/86fa583bf41a0cb931ab6980b477fe47929f406b","head":{"label":"hejare:batch-fetch","ref":"batch-fetch","sha":"86fa583bf41a0cb931ab6980b477fe47929f406b","user":{"login":"hejare","id":25483351,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI1NDgzMzUx","avatar_url":"https://avatars2.githubusercontent.com/u/25483351?v=4","gravatar_id":"","url":"https://api.github.com/users/hejare","html_url":"https://github.com/hejare","followers_url":"https://api.github.com/users/hejare/followers","following_url":"https://api.github.com/users/hejare/following{/other_user}","gists_url":"https://api.github.com/users/hejare/gists{/gist_id}","starred_url":"https://api.github.com/users/hejare/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hejare/subscriptions","organizations_url":"https://api.github.com/users/hejare/orgs","repos_url":"https://api.github.com/users/hejare/repos","events_url":"https://api.github.com/users/hejare/events{/privacy}","received_events_url":"https://api.github.com/users/hejare/received_events","type":"Organization","site_admin":false},"repo":{"id":142909578,"node_id":"MDEwOlJlcG9zaXRvcnkxNDI5MDk1Nzg=","name":"aws-motioner-data","full_name":"hejare/aws-motioner-data","private":false,"owner":{"login":"hejare","id":25483351,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI1NDgzMzUx","avatar_url":"https://avatars2.githubusercontent.com/u/25483351?v=4","gravatar_id":"","url":"https://api.github.com/users/hejare","html_url":"https://github.com/hejare","followers_url":"https://api.github.com/users/hejare/followers","following_url":"https://api.github.com/users/hejare/following{/other_user}","gists_url":"https://api.github.com/users/hejare/gists{/gist_id}","starred_url":"https://api.github.com/users/hejare/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hejare/subscriptions","organizations_url":"https://api.github.com/users/hejare/orgs","repos_url":"https://api.github.com/users/hejare/repos","events_url":"https://api.github.com/users/hejare/events{/privacy}","received_events_url":"https://api.github.com/users/hejare/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/hejare/aws-motioner-data","description":null,"fork":false,"url":"https://api.github.com/repos/hejare/aws-motioner-data","forks_url":"https://api.github.com/repos/hejare/aws-motioner-data/forks","keys_url":"https://api.github.com/repos/hejare/aws-motioner-data/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hejare/aws-motioner-data/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hejare/aws-motioner-data/teams","hooks_url":"https://api.github.com/repos/hejare/aws-motioner-data/hooks","issue_events_url":"https://api.github.com/repos/hejare/aws-motioner-data/issues/events{/number}","events_url":"https://api.github.com/repos/hejare/aws-motioner-data/events","assignees_url":"https://api.github.com/repos/hejare/aws-motioner-data/assignees{/user}","branches_url":"https://api.github.com/repos/hejare/aws-motioner-data/branches{/branch}","tags_url":"https://api.github.com/repos/hejare/aws-motioner-data/tags","blobs_url":"https://api.github.com/repos/hejare/aws-motioner-data/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hejare/aws-motioner-data/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hejare/aws-motioner-data/git/refs{/sha}","trees_url":"https://api.github.com/repos/hejare/aws-motioner-data/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hejare/aws-motioner-data/statuses/{sha}","languages_url":"https://api.github.com/repos/hejare/aws-motioner-data/languages","stargazers_url":"https://api.github.com/repos/hejare/aws-motioner-data/stargazers","contributors_url":"https://api.github.com/repos/hejare/aws-motioner-data/contributors","subscribers_url":"https://api.github.com/repos/hejare/aws-motioner-data/subscribers","subscription_url":"https://api.github.com/repos/hejare/aws-motioner-data/subscription","commits_url":"https://api.github.com/repos/hejare/aws-motioner-data/commits{/sha}","git_commits_url":"https://api.github.com/repos/hejare/aws-motioner-data/git/commits{/sha}","comments_url":"https://api.github.com/repos/hejare/aws-motioner-data/comments{/number}","issue_comment_url":"https://api.github.com/repos/hejare/aws-motioner-data/issues/comments{/number}","contents_url":"https://api.github.com/repos/hejare/aws-motioner-data/contents/{+path}","compare_url":"https://api.github.com/repos/hejare/aws-motioner-data/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hejare/aws-motioner-data/merges","archive_url":"https://api.github.com/repos/hejare/aws-motioner-data/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hejare/aws-motioner-data/downloads","issues_url":"https://api.github.com/repos/hejare/aws-motioner-data/issues{/number}","pulls_url":"https://api.github.com/repos/hejare/aws-motioner-data/pulls{/number}","milestones_url":"https://api.github.com/repos/hejare/aws-motioner-data/milestones{/number}","notifications_url":"https://api.github.com/repos/hejare/aws-motioner-data/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hejare/aws-motioner-data/labels{/name}","releases_url":"https://api.github.com/repos/hejare/aws-motioner-data/releases{/id}","deployments_url":"https://api.github.com/repos/hejare/aws-motioner-data/deployments","created_at":"2018-07-30T17:53:20Z","updated_at":"2018-11-08T21:36:30Z","pushed_at":"2018-11-08T21:39:35Z","git_url":"git://github.com/hejare/aws-motioner-data.git","ssh_url":"git@github.com:hejare/aws-motioner-data.git","clone_url":"https://github.com/hejare/aws-motioner-data.git","svn_url":"https://github.com/hejare/aws-motioner-data","homepage":null,"size":764,"stargazers_count":2,"watchers_count":2,"language":"HTML","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":10,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0","node_id":"MDc6TGljZW5zZTk="},"forks":0,"open_issues":10,"watchers":2,"default_branch":"master"}},"base":{"label":"hejare:master","ref":"master","sha":"b3059132bb17250b7fe0ee379f882a9f464b075f","user":{"login":"hejare","id":25483351,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI1NDgzMzUx","avatar_url":"https://avatars2.githubusercontent.com/u/25483351?v=4","gravatar_id":"","url":"https://api.github.com/users/hejare","html_url":"https://github.com/hejare","followers_url":"https://api.github.com/users/hejare/followers","following_url":"https://api.github.com/users/hejare/following{/other_user}","gists_url":"https://api.github.com/users/hejare/gists{/gist_id}","starred_url":"https://api.github.com/users/hejare/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hejare/subscriptions","organizations_url":"https://api.github.com/users/hejare/orgs","repos_url":"https://api.github.com/users/hejare/repos","events_url":"https://api.github.com/users/hejare/events{/privacy}","received_events_url":"https://api.github.com/users/hejare/received_events","type":"Organization","site_admin":false},"repo":{"id":142909578,"node_id":"MDEwOlJlcG9zaXRvcnkxNDI5MDk1Nzg=","name":"aws-motioner-data","full_name":"hejare/aws-motioner-data","private":false,"owner":{"login":"hejare","id":25483351,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI1NDgzMzUx","avatar_url":"https://avatars2.githubusercontent.com/u/25483351?v=4","gravatar_id":"","url":"https://api.github.com/users/hejare","html_url":"https://github.com/hejare","followers_url":"https://api.github.com/users/hejare/followers","following_url":"https://api.github.com/users/hejare/following{/other_user}","gists_url":"https://api.github.com/users/hejare/gists{/gist_id}","starred_url":"https://api.github.com/users/hejare/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hejare/subscriptions","organizations_url":"https://api.github.com/users/hejare/orgs","repos_url":"https://api.github.com/users/hejare/repos","events_url":"https://api.github.com/users/hejare/events{/privacy}","received_events_url":"https://api.github.com/users/hejare/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/hejare/aws-motioner-data","description":null,"fork":false,"url":"https://api.github.com/repos/hejare/aws-motioner-data","forks_url":"https://api.github.com/repos/hejare/aws-motioner-data/forks","keys_url":"https://api.github.com/repos/hejare/aws-motioner-data/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hejare/aws-motioner-data/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hejare/aws-motioner-data/teams","hooks_url":"https://api.github.com/repos/hejare/aws-motioner-data/hooks","issue_events_url":"https://api.github.com/repos/hejare/aws-motioner-data/issues/events{/number}","events_url":"https://api.github.com/repos/hejare/aws-motioner-data/events","assignees_url":"https://api.github.com/repos/hejare/aws-motioner-data/assignees{/user}","branches_url":"https://api.github.com/repos/hejare/aws-motioner-data/branches{/branch}","tags_url":"https://api.github.com/repos/hejare/aws-motioner-data/tags","blobs_url":"https://api.github.com/repos/hejare/aws-motioner-data/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hejare/aws-motioner-data/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hejare/aws-motioner-data/git/refs{/sha}","trees_url":"https://api.github.com/repos/hejare/aws-motioner-data/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hejare/aws-motioner-data/statuses/{sha}","languages_url":"https://api.github.com/repos/hejare/aws-motioner-data/languages","stargazers_url":"https://api.github.com/repos/hejare/aws-motioner-data/stargazers","contributors_url":"https://api.github.com/repos/hejare/aws-motioner-data/contributors","subscribers_url":"https://api.github.com/repos/hejare/aws-motioner-data/subscribers","subscription_url":"https://api.github.com/repos/hejare/aws-motioner-data/subscription","commits_url":"https://api.github.com/repos/hejare/aws-motioner-data/commits{/sha}","git_commits_url":"https://api.github.com/repos/hejare/aws-motioner-data/git/commits{/sha}","comments_url":"https://api.github.com/repos/hejare/aws-motioner-data/comments{/number}","issue_comment_url":"https://api.github.com/repos/hejare/aws-motioner-data/issues/comments{/number}","contents_url":"https://api.github.com/repos/hejare/aws-motioner-data/contents/{+path}","compare_url":"https://api.github.com/repos/hejare/aws-motioner-data/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hejare/aws-motioner-data/merges","archive_url":"https://api.github.com/repos/hejare/aws-motioner-data/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hejare/aws-motioner-data/downloads","issues_url":"https://api.github.com/repos/hejare/aws-motioner-data/issues{/number}","pulls_url":"https://api.github.com/repos/hejare/aws-motioner-data/pulls{/number}","milestones_url":"https://api.github.com/repos/hejare/aws-motioner-data/milestones{/number}","notifications_url":"https://api.github.com/repos/hejare/aws-motioner-data/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hejare/aws-motioner-data/labels{/name}","releases_url":"https://api.github.com/repos/hejare/aws-motioner-data/releases{/id}","deployments_url":"https://api.github.com/repos/hejare/aws-motioner-data/deployments","created_at":"2018-07-30T17:53:20Z","updated_at":"2018-11-08T21:36:30Z","pushed_at":"2018-11-08T21:39:35Z","git_url":"git://github.com/hejare/aws-motioner-data.git","ssh_url":"git@github.com:hejare/aws-motioner-data.git","clone_url":"https://github.com/hejare/aws-motioner-data.git","svn_url":"https://github.com/hejare/aws-motioner-data","homepage":null,"size":764,"stargazers_count":2,"watchers_count":2,"language":"HTML","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":10,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0","node_id":"MDc6TGljZW5zZTk="},"forks":0,"open_issues":10,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/hejare/aws-motioner-data/pulls/44"},"html":{"href":"https://github.com/hejare/aws-motioner-data/pull/44"},"issue":{"href":"https://api.github.com/repos/hejare/aws-motioner-data/issues/44"},"comments":{"href":"https://api.github.com/repos/hejare/aws-motioner-data/issues/44/comments"},"review_comments":{"href":"https://api.github.com/repos/hejare/aws-motioner-data/pulls/44/comments"},"review_comment":{"href":"https://api.github.com/repos/hejare/aws-motioner-data/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/hejare/aws-motioner-data/pulls/44/commits"},"statuses":{"href":"https://api.github.com/repos/hejare/aws-motioner-data/statuses/86fa583bf41a0cb931ab6980b477fe47929f406b"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"yvonnele"}}