{"action":"created","comment":{"url":"https://api.github.com/repos/netguru/access/pulls/comments/46758562","id":46758562,"diff_hunk":"@@ -102,28 +126,38 @@ def activate_member(uid)\n       toggl_client.update_workspace_user(workspace_user['id'], params)\n     end\n \n-    def preload_projects_users(team_ids)\n+    def preload_projects_users_with_tasks(team_ids)\n       input = Queue.new\n       result = Queue.new\n-      team_ids.each { |team_id| input << team_id unless projects_users.key?(team_id.to_i) }\n-      threads = (1..THREAD_POOL_SIZE).map do\n-        thread_block = build_preload_projects_users_thread_block(input, result)\n-        Thread.new(self.class.new(@token, @company_name), &thread_block)\n-      end\n+      prepare_teams_ids(team_ids)\n+      threads = start_threads(input, result)\n       threads.each(&:join)\n       until result.empty?\n-        team_id, project_users = result.pop\n+        team_id, project_users, project_tasks = result.pop\n         projects_users[team_id.to_i] = project_users\n+        projects_tasks[team_id.to_i] = project_tasks\n+      end\n+    end\n+\n+    def prepare_teams_ids(team_ids)\n+      team_ids.each { |team_id| input << team_id unless projects_users.key?(team_id.to_i) }","path":"app/models/toggl_integration/api.rb","position":85,"original_position":85,"commit_id":"a35496618d2a95a36e20e670c6384f1998fbb09b","original_commit_id":"a35496618d2a95a36e20e670c6384f1998fbb09b","user":{"login":"lubieniebieski","id":134795,"avatar_url":"https://avatars.githubusercontent.com/u/134795?v=3","gravatar_id":"","url":"https://api.github.com/users/lubieniebieski","html_url":"https://github.com/lubieniebieski","followers_url":"https://api.github.com/users/lubieniebieski/followers","following_url":"https://api.github.com/users/lubieniebieski/following{/other_user}","gists_url":"https://api.github.com/users/lubieniebieski/gists{/gist_id}","starred_url":"https://api.github.com/users/lubieniebieski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lubieniebieski/subscriptions","organizations_url":"https://api.github.com/users/lubieniebieski/orgs","repos_url":"https://api.github.com/users/lubieniebieski/repos","events_url":"https://api.github.com/users/lubieniebieski/events{/privacy}","received_events_url":"https://api.github.com/users/lubieniebieski/received_events","type":"User","site_admin":false},"body":"see my comment above - you can replace `each` with `select` here","created_at":"2015-12-05T13:55:23Z","updated_at":"2015-12-05T13:55:23Z","html_url":"https://github.com/netguru/access/pull/8#discussion_r46758562","pull_request_url":"https://api.github.com/repos/netguru/access/pulls/8","_links":{"self":{"href":"https://api.github.com/repos/netguru/access/pulls/comments/46758562"},"html":{"href":"https://github.com/netguru/access/pull/8#discussion_r46758562"},"pull_request":{"href":"https://api.github.com/repos/netguru/access/pulls/8"}}},"pull_request":{"url":"https://api.github.com/repos/netguru/access/pulls/8","id":52507662,"html_url":"https://github.com/netguru/access/pull/8","diff_url":"https://github.com/netguru/access/pull/8.diff","patch_url":"https://github.com/netguru/access/pull/8.patch","issue_url":"https://api.github.com/repos/netguru/access/issues/8","number":8,"state":"open","locked":false,"title":"Toggl task","user":{"login":"mtczerwinski","id":644275,"avatar_url":"https://avatars.githubusercontent.com/u/644275?v=3","gravatar_id":"","url":"https://api.github.com/users/mtczerwinski","html_url":"https://github.com/mtczerwinski","followers_url":"https://api.github.com/users/mtczerwinski/followers","following_url":"https://api.github.com/users/mtczerwinski/following{/other_user}","gists_url":"https://api.github.com/users/mtczerwinski/gists{/gist_id}","starred_url":"https://api.github.com/users/mtczerwinski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mtczerwinski/subscriptions","organizations_url":"https://api.github.com/users/mtczerwinski/orgs","repos_url":"https://api.github.com/users/mtczerwinski/repos","events_url":"https://api.github.com/users/mtczerwinski/events{/privacy}","received_events_url":"https://api.github.com/users/mtczerwinski/received_events","type":"User","site_admin":false},"body":"I added the functionality which allows to add or remove tasks from permissions (YAML files).","created_at":"2015-12-03T09:08:31Z","updated_at":"2015-12-05T13:55:23Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1cb9138e70c8e7b978d81a0d4d8ca48945344feb","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/netguru/access/pulls/8/commits","review_comments_url":"https://api.github.com/repos/netguru/access/pulls/8/comments","review_comment_url":"https://api.github.com/repos/netguru/access/pulls/comments{/number}","comments_url":"https://api.github.com/repos/netguru/access/issues/8/comments","statuses_url":"https://api.github.com/repos/netguru/access/statuses/a35496618d2a95a36e20e670c6384f1998fbb09b","head":{"label":"netguru:toggl_task","ref":"toggl_task","sha":"a35496618d2a95a36e20e670c6384f1998fbb09b","user":{"login":"netguru","id":1146,"avatar_url":"https://avatars.githubusercontent.com/u/1146?v=3","gravatar_id":"","url":"https://api.github.com/users/netguru","html_url":"https://github.com/netguru","followers_url":"https://api.github.com/users/netguru/followers","following_url":"https://api.github.com/users/netguru/following{/other_user}","gists_url":"https://api.github.com/users/netguru/gists{/gist_id}","starred_url":"https://api.github.com/users/netguru/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/netguru/subscriptions","organizations_url":"https://api.github.com/users/netguru/orgs","repos_url":"https://api.github.com/users/netguru/repos","events_url":"https://api.github.com/users/netguru/events{/privacy}","received_events_url":"https://api.github.com/users/netguru/received_events","type":"Organization","site_admin":false},"repo":{"id":24055977,"name":"access","full_name":"netguru/access","owner":{"login":"netguru","id":1146,"avatar_url":"https://avatars.githubusercontent.com/u/1146?v=3","gravatar_id":"","url":"https://api.github.com/users/netguru","html_url":"https://github.com/netguru","followers_url":"https://api.github.com/users/netguru/followers","following_url":"https://api.github.com/users/netguru/following{/other_user}","gists_url":"https://api.github.com/users/netguru/gists{/gist_id}","starred_url":"https://api.github.com/users/netguru/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/netguru/subscriptions","organizations_url":"https://api.github.com/users/netguru/orgs","repos_url":"https://api.github.com/users/netguru/repos","events_url":"https://api.github.com/users/netguru/events{/privacy}","received_events_url":"https://api.github.com/users/netguru/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/netguru/access","description":"Push style access app for github and google apps","fork":false,"url":"https://api.github.com/repos/netguru/access","forks_url":"https://api.github.com/repos/netguru/access/forks","keys_url":"https://api.github.com/repos/netguru/access/keys{/key_id}","collaborators_url":"https://api.github.com/repos/netguru/access/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/netguru/access/teams","hooks_url":"https://api.github.com/repos/netguru/access/hooks","issue_events_url":"https://api.github.com/repos/netguru/access/issues/events{/number}","events_url":"https://api.github.com/repos/netguru/access/events","assignees_url":"https://api.github.com/repos/netguru/access/assignees{/user}","branches_url":"https://api.github.com/repos/netguru/access/branches{/branch}","tags_url":"https://api.github.com/repos/netguru/access/tags","blobs_url":"https://api.github.com/repos/netguru/access/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/netguru/access/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/netguru/access/git/refs{/sha}","trees_url":"https://api.github.com/repos/netguru/access/git/trees{/sha}","statuses_url":"https://api.github.com/repos/netguru/access/statuses/{sha}","languages_url":"https://api.github.com/repos/netguru/access/languages","stargazers_url":"https://api.github.com/repos/netguru/access/stargazers","contributors_url":"https://api.github.com/repos/netguru/access/contributors","subscribers_url":"https://api.github.com/repos/netguru/access/subscribers","subscription_url":"https://api.github.com/repos/netguru/access/subscription","commits_url":"https://api.github.com/repos/netguru/access/commits{/sha}","git_commits_url":"https://api.github.com/repos/netguru/access/git/commits{/sha}","comments_url":"https://api.github.com/repos/netguru/access/comments{/number}","issue_comment_url":"https://api.github.com/repos/netguru/access/issues/comments{/number}","contents_url":"https://api.github.com/repos/netguru/access/contents/{+path}","compare_url":"https://api.github.com/repos/netguru/access/compare/{base}...{head}","merges_url":"https://api.github.com/repos/netguru/access/merges","archive_url":"https://api.github.com/repos/netguru/access/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/netguru/access/downloads","issues_url":"https://api.github.com/repos/netguru/access/issues{/number}","pulls_url":"https://api.github.com/repos/netguru/access/pulls{/number}","milestones_url":"https://api.github.com/repos/netguru/access/milestones{/number}","notifications_url":"https://api.github.com/repos/netguru/access/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/netguru/access/labels{/name}","releases_url":"https://api.github.com/repos/netguru/access/releases{/id}","created_at":"2014-09-15T12:43:28Z","updated_at":"2015-07-27T08:15:29Z","pushed_at":"2015-12-05T12:14:31Z","git_url":"git://github.com/netguru/access.git","ssh_url":"git@github.com:netguru/access.git","clone_url":"https://github.com/netguru/access.git","svn_url":"https://github.com/netguru/access","homepage":"https://netguru.co/opensource","size":22741,"stargazers_count":3,"watchers_count":3,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":2,"forks":5,"open_issues":2,"watchers":3,"default_branch":"master"}},"base":{"label":"netguru:master","ref":"master","sha":"1b41631703a29c88608c7090a821d4d7137611b3","user":{"login":"netguru","id":1146,"avatar_url":"https://avatars.githubusercontent.com/u/1146?v=3","gravatar_id":"","url":"https://api.github.com/users/netguru","html_url":"https://github.com/netguru","followers_url":"https://api.github.com/users/netguru/followers","following_url":"https://api.github.com/users/netguru/following{/other_user}","gists_url":"https://api.github.com/users/netguru/gists{/gist_id}","starred_url":"https://api.github.com/users/netguru/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/netguru/subscriptions","organizations_url":"https://api.github.com/users/netguru/orgs","repos_url":"https://api.github.com/users/netguru/repos","events_url":"https://api.github.com/users/netguru/events{/privacy}","received_events_url":"https://api.github.com/users/netguru/received_events","type":"Organization","site_admin":false},"repo":{"id":24055977,"name":"access","full_name":"netguru/access","owner":{"login":"netguru","id":1146,"avatar_url":"https://avatars.githubusercontent.com/u/1146?v=3","gravatar_id":"","url":"https://api.github.com/users/netguru","html_url":"https://github.com/netguru","followers_url":"https://api.github.com/users/netguru/followers","following_url":"https://api.github.com/users/netguru/following{/other_user}","gists_url":"https://api.github.com/users/netguru/gists{/gist_id}","starred_url":"https://api.github.com/users/netguru/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/netguru/subscriptions","organizations_url":"https://api.github.com/users/netguru/orgs","repos_url":"https://api.github.com/users/netguru/repos","events_url":"https://api.github.com/users/netguru/events{/privacy}","received_events_url":"https://api.github.com/users/netguru/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/netguru/access","description":"Push style access app for github and google apps","fork":false,"url":"https://api.github.com/repos/netguru/access","forks_url":"https://api.github.com/repos/netguru/access/forks","keys_url":"https://api.github.com/repos/netguru/access/keys{/key_id}","collaborators_url":"https://api.github.com/repos/netguru/access/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/netguru/access/teams","hooks_url":"https://api.github.com/repos/netguru/access/hooks","issue_events_url":"https://api.github.com/repos/netguru/access/issues/events{/number}","events_url":"https://api.github.com/repos/netguru/access/events","assignees_url":"https://api.github.com/repos/netguru/access/assignees{/user}","branches_url":"https://api.github.com/repos/netguru/access/branches{/branch}","tags_url":"https://api.github.com/repos/netguru/access/tags","blobs_url":"https://api.github.com/repos/netguru/access/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/netguru/access/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/netguru/access/git/refs{/sha}","trees_url":"https://api.github.com/repos/netguru/access/git/trees{/sha}","statuses_url":"https://api.github.com/repos/netguru/access/statuses/{sha}","languages_url":"https://api.github.com/repos/netguru/access/languages","stargazers_url":"https://api.github.com/repos/netguru/access/stargazers","contributors_url":"https://api.github.com/repos/netguru/access/contributors","subscribers_url":"https://api.github.com/repos/netguru/access/subscribers","subscription_url":"https://api.github.com/repos/netguru/access/subscription","commits_url":"https://api.github.com/repos/netguru/access/commits{/sha}","git_commits_url":"https://api.github.com/repos/netguru/access/git/commits{/sha}","comments_url":"https://api.github.com/repos/netguru/access/comments{/number}","issue_comment_url":"https://api.github.com/repos/netguru/access/issues/comments{/number}","contents_url":"https://api.github.com/repos/netguru/access/contents/{+path}","compare_url":"https://api.github.com/repos/netguru/access/compare/{base}...{head}","merges_url":"https://api.github.com/repos/netguru/access/merges","archive_url":"https://api.github.com/repos/netguru/access/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/netguru/access/downloads","issues_url":"https://api.github.com/repos/netguru/access/issues{/number}","pulls_url":"https://api.github.com/repos/netguru/access/pulls{/number}","milestones_url":"https://api.github.com/repos/netguru/access/milestones{/number}","notifications_url":"https://api.github.com/repos/netguru/access/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/netguru/access/labels{/name}","releases_url":"https://api.github.com/repos/netguru/access/releases{/id}","created_at":"2014-09-15T12:43:28Z","updated_at":"2015-07-27T08:15:29Z","pushed_at":"2015-12-05T12:14:31Z","git_url":"git://github.com/netguru/access.git","ssh_url":"git@github.com:netguru/access.git","clone_url":"https://github.com/netguru/access.git","svn_url":"https://github.com/netguru/access","homepage":"https://netguru.co/opensource","size":22741,"stargazers_count":3,"watchers_count":3,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":2,"forks":5,"open_issues":2,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/netguru/access/pulls/8"},"html":{"href":"https://github.com/netguru/access/pull/8"},"issue":{"href":"https://api.github.com/repos/netguru/access/issues/8"},"comments":{"href":"https://api.github.com/repos/netguru/access/issues/8/comments"},"review_comments":{"href":"https://api.github.com/repos/netguru/access/pulls/8/comments"},"review_comment":{"href":"https://api.github.com/repos/netguru/access/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/netguru/access/pulls/8/commits"},"statuses":{"href":"https://api.github.com/repos/netguru/access/statuses/a35496618d2a95a36e20e670c6384f1998fbb09b"}}}}