{"action":"created","comment":{"url":"https://api.github.com/repos/kiev-ruby/redwings/pulls/comments/36629351","id":36629351,"diff_hunk":"@@ -66,21 +69,40 @@ def self.setup_academy_tasks\n       process_lists = TrelloApi::Board.lists board_process[:id]\n \n       Project.find_by(name: 'Academy').users.active.each do |db_user|\n-        username = convert_to_trello_username db_user.username\n-\n-        unless process_lists.any? { |list| list[:name] == username }\n-          new_list_name = convert_to_trello_username db_user.username\n+        unless process_lists.any? { |list| list[:name] == db_user.trello_username }\n           list_source   = list_in_board(LIST_TASKS, BOARD_KNOWLEDGE)\n-          TrelloApi::List.add_list_to_board(new_list_name, board_process[:id], list_source[:id])\n+          TrelloApi::List.add_list_to_board(db_user.trello_username, board_process[:id], list_source[:id])\n         end\n       end\n     end\n \n-    def self.update_academy_tasks_time\n-      @project = Project.find_by(name: \"Academy\")\n-      @project.data = { 'total_tasks_time' => total_tasks_time,\n-                        'time_for_project' => 30 * 24 * 60 * 60 }\n-      @project.save\n+    def self.update_academy_tasks_total_time\n+      knowledge_list = list_in_board(LIST_TASKS, BOARD_KNOWLEDGE)\n+\n+      project = Project.find_by(name: \"Academy\")\n+      project.data['total_tasks_time'] = total_tasks_time(knowledge_list, 'incomplete')\n+      project.data['time_for_project'] = 30 * 24 * 60 * 60\n+      project.save\n+    end\n+\n+    def self.update_academy_tasks_spent_time\n+      board_process = board_by_name BOARD_PROCESS\n+      project_id = Project.find_by(name: 'Academy').id\n+\n+      TrelloApi::Board.lists(board_process[:id]).each do |list|\n+        user = User.find_by(trello_username: list[:name])\n+\n+        projects_user = ProjectsUser.find_by(project_id: project_id, user_id: user.id)\n+        projects_user.data['spent_time'] = total_tasks_time(list, 'complete')\n+        projects_user.save\n+      end\n+    end\n+\n+    def self.update_trello_usernames\n+      User.active.each do |user|\n+        user.trello_username = convert_to_trello_username user.username\n+        user.save\n+      end","path":"lib/service/trello.rb","position":76,"original_position":76,"commit_id":"8dd9030f87cd7e065ffe1247b52ee8e11952354d","original_commit_id":"8dd9030f87cd7e065ffe1247b52ee8e11952354d","user":{"login":"95kach","id":10588116,"avatar_url":"https://avatars.githubusercontent.com/u/10588116?v=3","gravatar_id":"","url":"https://api.github.com/users/95kach","html_url":"https://github.com/95kach","followers_url":"https://api.github.com/users/95kach/followers","following_url":"https://api.github.com/users/95kach/following{/other_user}","gists_url":"https://api.github.com/users/95kach/gists{/gist_id}","starred_url":"https://api.github.com/users/95kach/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/95kach/subscriptions","organizations_url":"https://api.github.com/users/95kach/orgs","repos_url":"https://api.github.com/users/95kach/repos","events_url":"https://api.github.com/users/95kach/events{/privacy}","received_events_url":"https://api.github.com/users/95kach/received_events","type":"User","site_admin":false},"body":"думал добавить на случай, если кто то поменяет свой слек юзернейм, то придется каждый раз вводить этот скрипт.","created_at":"2015-08-10T13:21:35Z","updated_at":"2015-08-10T13:21:35Z","html_url":"https://github.com/kiev-ruby/redwings/pull/84#discussion_r36629351","pull_request_url":"https://api.github.com/repos/kiev-ruby/redwings/pulls/84","_links":{"self":{"href":"https://api.github.com/repos/kiev-ruby/redwings/pulls/comments/36629351"},"html":{"href":"https://github.com/kiev-ruby/redwings/pull/84#discussion_r36629351"},"pull_request":{"href":"https://api.github.com/repos/kiev-ruby/redwings/pulls/84"}}},"pull_request":{"url":"https://api.github.com/repos/kiev-ruby/redwings/pulls/84","id":41971746,"html_url":"https://github.com/kiev-ruby/redwings/pull/84","diff_url":"https://github.com/kiev-ruby/redwings/pull/84.diff","patch_url":"https://github.com/kiev-ruby/redwings/pull/84.patch","issue_url":"https://api.github.com/repos/kiev-ruby/redwings/issues/84","number":84,"state":"open","locked":false,"title":"update users academy tasks spent time","user":{"login":"95kach","id":10588116,"avatar_url":"https://avatars.githubusercontent.com/u/10588116?v=3","gravatar_id":"","url":"https://api.github.com/users/95kach","html_url":"https://github.com/95kach","followers_url":"https://api.github.com/users/95kach/followers","following_url":"https://api.github.com/users/95kach/following{/other_user}","gists_url":"https://api.github.com/users/95kach/gists{/gist_id}","starred_url":"https://api.github.com/users/95kach/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/95kach/subscriptions","organizations_url":"https://api.github.com/users/95kach/orgs","repos_url":"https://api.github.com/users/95kach/repos","events_url":"https://api.github.com/users/95kach/events{/privacy}","received_events_url":"https://api.github.com/users/95kach/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-08-09T15:08:06Z","updated_at":"2015-08-10T13:21:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9c6272fd9480c2b80fd16d189e12cb5770eda607","assignee":{"login":"beornborn","id":1485786,"avatar_url":"https://avatars.githubusercontent.com/u/1485786?v=3","gravatar_id":"","url":"https://api.github.com/users/beornborn","html_url":"https://github.com/beornborn","followers_url":"https://api.github.com/users/beornborn/followers","following_url":"https://api.github.com/users/beornborn/following{/other_user}","gists_url":"https://api.github.com/users/beornborn/gists{/gist_id}","starred_url":"https://api.github.com/users/beornborn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/beornborn/subscriptions","organizations_url":"https://api.github.com/users/beornborn/orgs","repos_url":"https://api.github.com/users/beornborn/repos","events_url":"https://api.github.com/users/beornborn/events{/privacy}","received_events_url":"https://api.github.com/users/beornborn/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/kiev-ruby/redwings/pulls/84/commits","review_comments_url":"https://api.github.com/repos/kiev-ruby/redwings/pulls/84/comments","review_comment_url":"https://api.github.com/repos/kiev-ruby/redwings/pulls/comments{/number}","comments_url":"https://api.github.com/repos/kiev-ruby/redwings/issues/84/comments","statuses_url":"https://api.github.com/repos/kiev-ruby/redwings/statuses/8dd9030f87cd7e065ffe1247b52ee8e11952354d","head":{"label":"kiev-ruby:feature/spent_time","ref":"feature/spent_time","sha":"8dd9030f87cd7e065ffe1247b52ee8e11952354d","user":{"login":"kiev-ruby","id":11543510,"avatar_url":"https://avatars.githubusercontent.com/u/11543510?v=3","gravatar_id":"","url":"https://api.github.com/users/kiev-ruby","html_url":"https://github.com/kiev-ruby","followers_url":"https://api.github.com/users/kiev-ruby/followers","following_url":"https://api.github.com/users/kiev-ruby/following{/other_user}","gists_url":"https://api.github.com/users/kiev-ruby/gists{/gist_id}","starred_url":"https://api.github.com/users/kiev-ruby/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kiev-ruby/subscriptions","organizations_url":"https://api.github.com/users/kiev-ruby/orgs","repos_url":"https://api.github.com/users/kiev-ruby/repos","events_url":"https://api.github.com/users/kiev-ruby/events{/privacy}","received_events_url":"https://api.github.com/users/kiev-ruby/received_events","type":"Organization","site_admin":false},"repo":{"id":36972191,"name":"redwings","full_name":"kiev-ruby/redwings","owner":{"login":"kiev-ruby","id":11543510,"avatar_url":"https://avatars.githubusercontent.com/u/11543510?v=3","gravatar_id":"","url":"https://api.github.com/users/kiev-ruby","html_url":"https://github.com/kiev-ruby","followers_url":"https://api.github.com/users/kiev-ruby/followers","following_url":"https://api.github.com/users/kiev-ruby/following{/other_user}","gists_url":"https://api.github.com/users/kiev-ruby/gists{/gist_id}","starred_url":"https://api.github.com/users/kiev-ruby/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kiev-ruby/subscriptions","organizations_url":"https://api.github.com/users/kiev-ruby/orgs","repos_url":"https://api.github.com/users/kiev-ruby/repos","events_url":"https://api.github.com/users/kiev-ruby/events{/privacy}","received_events_url":"https://api.github.com/users/kiev-ruby/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/kiev-ruby/redwings","description":"team management service","fork":false,"url":"https://api.github.com/repos/kiev-ruby/redwings","forks_url":"https://api.github.com/repos/kiev-ruby/redwings/forks","keys_url":"https://api.github.com/repos/kiev-ruby/redwings/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kiev-ruby/redwings/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kiev-ruby/redwings/teams","hooks_url":"https://api.github.com/repos/kiev-ruby/redwings/hooks","issue_events_url":"https://api.github.com/repos/kiev-ruby/redwings/issues/events{/number}","events_url":"https://api.github.com/repos/kiev-ruby/redwings/events","assignees_url":"https://api.github.com/repos/kiev-ruby/redwings/assignees{/user}","branches_url":"https://api.github.com/repos/kiev-ruby/redwings/branches{/branch}","tags_url":"https://api.github.com/repos/kiev-ruby/redwings/tags","blobs_url":"https://api.github.com/repos/kiev-ruby/redwings/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kiev-ruby/redwings/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kiev-ruby/redwings/git/refs{/sha}","trees_url":"https://api.github.com/repos/kiev-ruby/redwings/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kiev-ruby/redwings/statuses/{sha}","languages_url":"https://api.github.com/repos/kiev-ruby/redwings/languages","stargazers_url":"https://api.github.com/repos/kiev-ruby/redwings/stargazers","contributors_url":"https://api.github.com/repos/kiev-ruby/redwings/contributors","subscribers_url":"https://api.github.com/repos/kiev-ruby/redwings/subscribers","subscription_url":"https://api.github.com/repos/kiev-ruby/redwings/subscription","commits_url":"https://api.github.com/repos/kiev-ruby/redwings/commits{/sha}","git_commits_url":"https://api.github.com/repos/kiev-ruby/redwings/git/commits{/sha}","comments_url":"https://api.github.com/repos/kiev-ruby/redwings/comments{/number}","issue_comment_url":"https://api.github.com/repos/kiev-ruby/redwings/issues/comments{/number}","contents_url":"https://api.github.com/repos/kiev-ruby/redwings/contents/{+path}","compare_url":"https://api.github.com/repos/kiev-ruby/redwings/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kiev-ruby/redwings/merges","archive_url":"https://api.github.com/repos/kiev-ruby/redwings/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kiev-ruby/redwings/downloads","issues_url":"https://api.github.com/repos/kiev-ruby/redwings/issues{/number}","pulls_url":"https://api.github.com/repos/kiev-ruby/redwings/pulls{/number}","milestones_url":"https://api.github.com/repos/kiev-ruby/redwings/milestones{/number}","notifications_url":"https://api.github.com/repos/kiev-ruby/redwings/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kiev-ruby/redwings/labels{/name}","releases_url":"https://api.github.com/repos/kiev-ruby/redwings/releases{/id}","created_at":"2015-06-06T07:53:33Z","updated_at":"2015-08-02T14:34:34Z","pushed_at":"2015-08-10T11:48:35Z","git_url":"git://github.com/kiev-ruby/redwings.git","ssh_url":"git@github.com:kiev-ruby/redwings.git","clone_url":"https://github.com/kiev-ruby/redwings.git","svn_url":"https://github.com/kiev-ruby/redwings","homepage":"https://redwings.herokuapp.com/","size":23248,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":5,"forks":0,"open_issues":5,"watchers":0,"default_branch":"develop"}},"base":{"label":"kiev-ruby:develop","ref":"develop","sha":"1f73139b4084ba6a918b19901afa85e2a1923cc1","user":{"login":"kiev-ruby","id":11543510,"avatar_url":"https://avatars.githubusercontent.com/u/11543510?v=3","gravatar_id":"","url":"https://api.github.com/users/kiev-ruby","html_url":"https://github.com/kiev-ruby","followers_url":"https://api.github.com/users/kiev-ruby/followers","following_url":"https://api.github.com/users/kiev-ruby/following{/other_user}","gists_url":"https://api.github.com/users/kiev-ruby/gists{/gist_id}","starred_url":"https://api.github.com/users/kiev-ruby/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kiev-ruby/subscriptions","organizations_url":"https://api.github.com/users/kiev-ruby/orgs","repos_url":"https://api.github.com/users/kiev-ruby/repos","events_url":"https://api.github.com/users/kiev-ruby/events{/privacy}","received_events_url":"https://api.github.com/users/kiev-ruby/received_events","type":"Organization","site_admin":false},"repo":{"id":36972191,"name":"redwings","full_name":"kiev-ruby/redwings","owner":{"login":"kiev-ruby","id":11543510,"avatar_url":"https://avatars.githubusercontent.com/u/11543510?v=3","gravatar_id":"","url":"https://api.github.com/users/kiev-ruby","html_url":"https://github.com/kiev-ruby","followers_url":"https://api.github.com/users/kiev-ruby/followers","following_url":"https://api.github.com/users/kiev-ruby/following{/other_user}","gists_url":"https://api.github.com/users/kiev-ruby/gists{/gist_id}","starred_url":"https://api.github.com/users/kiev-ruby/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kiev-ruby/subscriptions","organizations_url":"https://api.github.com/users/kiev-ruby/orgs","repos_url":"https://api.github.com/users/kiev-ruby/repos","events_url":"https://api.github.com/users/kiev-ruby/events{/privacy}","received_events_url":"https://api.github.com/users/kiev-ruby/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/kiev-ruby/redwings","description":"team management service","fork":false,"url":"https://api.github.com/repos/kiev-ruby/redwings","forks_url":"https://api.github.com/repos/kiev-ruby/redwings/forks","keys_url":"https://api.github.com/repos/kiev-ruby/redwings/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kiev-ruby/redwings/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kiev-ruby/redwings/teams","hooks_url":"https://api.github.com/repos/kiev-ruby/redwings/hooks","issue_events_url":"https://api.github.com/repos/kiev-ruby/redwings/issues/events{/number}","events_url":"https://api.github.com/repos/kiev-ruby/redwings/events","assignees_url":"https://api.github.com/repos/kiev-ruby/redwings/assignees{/user}","branches_url":"https://api.github.com/repos/kiev-ruby/redwings/branches{/branch}","tags_url":"https://api.github.com/repos/kiev-ruby/redwings/tags","blobs_url":"https://api.github.com/repos/kiev-ruby/redwings/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kiev-ruby/redwings/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kiev-ruby/redwings/git/refs{/sha}","trees_url":"https://api.github.com/repos/kiev-ruby/redwings/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kiev-ruby/redwings/statuses/{sha}","languages_url":"https://api.github.com/repos/kiev-ruby/redwings/languages","stargazers_url":"https://api.github.com/repos/kiev-ruby/redwings/stargazers","contributors_url":"https://api.github.com/repos/kiev-ruby/redwings/contributors","subscribers_url":"https://api.github.com/repos/kiev-ruby/redwings/subscribers","subscription_url":"https://api.github.com/repos/kiev-ruby/redwings/subscription","commits_url":"https://api.github.com/repos/kiev-ruby/redwings/commits{/sha}","git_commits_url":"https://api.github.com/repos/kiev-ruby/redwings/git/commits{/sha}","comments_url":"https://api.github.com/repos/kiev-ruby/redwings/comments{/number}","issue_comment_url":"https://api.github.com/repos/kiev-ruby/redwings/issues/comments{/number}","contents_url":"https://api.github.com/repos/kiev-ruby/redwings/contents/{+path}","compare_url":"https://api.github.com/repos/kiev-ruby/redwings/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kiev-ruby/redwings/merges","archive_url":"https://api.github.com/repos/kiev-ruby/redwings/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kiev-ruby/redwings/downloads","issues_url":"https://api.github.com/repos/kiev-ruby/redwings/issues{/number}","pulls_url":"https://api.github.com/repos/kiev-ruby/redwings/pulls{/number}","milestones_url":"https://api.github.com/repos/kiev-ruby/redwings/milestones{/number}","notifications_url":"https://api.github.com/repos/kiev-ruby/redwings/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kiev-ruby/redwings/labels{/name}","releases_url":"https://api.github.com/repos/kiev-ruby/redwings/releases{/id}","created_at":"2015-06-06T07:53:33Z","updated_at":"2015-08-02T14:34:34Z","pushed_at":"2015-08-10T11:48:35Z","git_url":"git://github.com/kiev-ruby/redwings.git","ssh_url":"git@github.com:kiev-ruby/redwings.git","clone_url":"https://github.com/kiev-ruby/redwings.git","svn_url":"https://github.com/kiev-ruby/redwings","homepage":"https://redwings.herokuapp.com/","size":23248,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":5,"forks":0,"open_issues":5,"watchers":0,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/kiev-ruby/redwings/pulls/84"},"html":{"href":"https://github.com/kiev-ruby/redwings/pull/84"},"issue":{"href":"https://api.github.com/repos/kiev-ruby/redwings/issues/84"},"comments":{"href":"https://api.github.com/repos/kiev-ruby/redwings/issues/84/comments"},"review_comments":{"href":"https://api.github.com/repos/kiev-ruby/redwings/pulls/84/comments"},"review_comment":{"href":"https://api.github.com/repos/kiev-ruby/redwings/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/kiev-ruby/redwings/pulls/84/commits"},"statuses":{"href":"https://api.github.com/repos/kiev-ruby/redwings/statuses/8dd9030f87cd7e065ffe1247b52ee8e11952354d"}}}}