{"action":"created","comment":{"url":"https://api.github.com/repos/LunarLogic/foosball-app/pulls/comments/208990038","pull_request_review_id":144915583,"id":208990038,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwODk5MDAzOA==","diff_hunk":"@@ -0,0 +1,32 @@\n+# frozen_string_literal: true\n+\n+module Slack\n+  class UserDataDownloader\n+    def initialize(\n+      auth_token: Rails.application.credentials.auth_token,\n+      faraday: Faraday.new\n+    )\n+      @auth_token = auth_token\n+      @faraday = faraday\n+    end\n+\n+    def call\n+      slack_data = get_users_data\n+      save_users_data(slack_data)\n+    end\n+\n+    private\n+\n+    def get_users_data\n+      @faraday.get do |req|\n+        req.url(\"https://slack.com/api/users.list\")\n+        req.headers['Authorization'] = \"Bearer #{@auth_token}\"\n+      end.body\n+    end\n+\n+    def save_users_data(slack_data)\n+      directory = Rails.root.join('config', 'slack_data.json')\n+      File.write(directory, slack_data)\n+    end","path":"app/services/slack/user_data_downloader.rb","position":30,"original_position":30,"commit_id":"7165c3b17225084f5662cadc4fd652c1a0cad5f0","original_commit_id":"7165c3b17225084f5662cadc4fd652c1a0cad5f0","user":{"login":"shadre","id":19561672,"node_id":"MDQ6VXNlcjE5NTYxNjcy","avatar_url":"https://avatars0.githubusercontent.com/u/19561672?v=4","gravatar_id":"","url":"https://api.github.com/users/shadre","html_url":"https://github.com/shadre","followers_url":"https://api.github.com/users/shadre/followers","following_url":"https://api.github.com/users/shadre/following{/other_user}","gists_url":"https://api.github.com/users/shadre/gists{/gist_id}","starred_url":"https://api.github.com/users/shadre/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shadre/subscriptions","organizations_url":"https://api.github.com/users/shadre/orgs","repos_url":"https://api.github.com/users/shadre/repos","events_url":"https://api.github.com/users/shadre/events{/privacy}","received_events_url":"https://api.github.com/users/shadre/received_events","type":"User","site_admin":false},"body":"Right now it seems like we are relying on a very happy path here.\r\n\r\nIt is an I/O operation and I would be very careful with this and consider all potential implications of such approach.\r\nSome that come to mind:\r\n- do we have to close the file after writing?\r\n- what happens if the request to slack API is not completed, e.g. gets timed-out?\r\n- what happens if we get corrupt data?\r\n- how can we verify the correctness of it? (maybe checking the response status?)\r\n\r\nI think there are more. I just post them there as open questions to consider.","created_at":"2018-08-09T16:09:44Z","updated_at":"2018-08-09T16:09:44Z","html_url":"https://github.com/LunarLogic/foosball-app/pull/149#discussion_r208990038","pull_request_url":"https://api.github.com/repos/LunarLogic/foosball-app/pulls/149","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/LunarLogic/foosball-app/pulls/comments/208990038"},"html":{"href":"https://github.com/LunarLogic/foosball-app/pull/149#discussion_r208990038"},"pull_request":{"href":"https://api.github.com/repos/LunarLogic/foosball-app/pulls/149"}}},"pull_request":{"url":"https://api.github.com/repos/LunarLogic/foosball-app/pulls/149","id":207355427,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA3MzU1NDI3","html_url":"https://github.com/LunarLogic/foosball-app/pull/149","diff_url":"https://github.com/LunarLogic/foosball-app/pull/149.diff","patch_url":"https://github.com/LunarLogic/foosball-app/pull/149.patch","issue_url":"https://api.github.com/repos/LunarLogic/foosball-app/issues/149","number":149,"state":"open","locked":false,"title":"Download users data from slack every day","user":{"login":"yzmopolis","id":23139274,"node_id":"MDQ6VXNlcjIzMTM5Mjc0","avatar_url":"https://avatars3.githubusercontent.com/u/23139274?v=4","gravatar_id":"","url":"https://api.github.com/users/yzmopolis","html_url":"https://github.com/yzmopolis","followers_url":"https://api.github.com/users/yzmopolis/followers","following_url":"https://api.github.com/users/yzmopolis/following{/other_user}","gists_url":"https://api.github.com/users/yzmopolis/gists{/gist_id}","starred_url":"https://api.github.com/users/yzmopolis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yzmopolis/subscriptions","organizations_url":"https://api.github.com/users/yzmopolis/orgs","repos_url":"https://api.github.com/users/yzmopolis/repos","events_url":"https://api.github.com/users/yzmopolis/events{/privacy}","received_events_url":"https://api.github.com/users/yzmopolis/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-08-09T15:26:11Z","updated_at":"2018-08-09T16:09:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8fd9050481a8976b63ba2e0700a2f9ad145b32c4","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/LunarLogic/foosball-app/pulls/149/commits","review_comments_url":"https://api.github.com/repos/LunarLogic/foosball-app/pulls/149/comments","review_comment_url":"https://api.github.com/repos/LunarLogic/foosball-app/pulls/comments{/number}","comments_url":"https://api.github.com/repos/LunarLogic/foosball-app/issues/149/comments","statuses_url":"https://api.github.com/repos/LunarLogic/foosball-app/statuses/7165c3b17225084f5662cadc4fd652c1a0cad5f0","head":{"label":"LunarLogic:update-slack-data","ref":"update-slack-data","sha":"7165c3b17225084f5662cadc4fd652c1a0cad5f0","user":{"login":"LunarLogic","id":32623,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMyNjIz","avatar_url":"https://avatars3.githubusercontent.com/u/32623?v=4","gravatar_id":"","url":"https://api.github.com/users/LunarLogic","html_url":"https://github.com/LunarLogic","followers_url":"https://api.github.com/users/LunarLogic/followers","following_url":"https://api.github.com/users/LunarLogic/following{/other_user}","gists_url":"https://api.github.com/users/LunarLogic/gists{/gist_id}","starred_url":"https://api.github.com/users/LunarLogic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LunarLogic/subscriptions","organizations_url":"https://api.github.com/users/LunarLogic/orgs","repos_url":"https://api.github.com/users/LunarLogic/repos","events_url":"https://api.github.com/users/LunarLogic/events{/privacy}","received_events_url":"https://api.github.com/users/LunarLogic/received_events","type":"Organization","site_admin":false},"repo":{"id":129111132,"node_id":"MDEwOlJlcG9zaXRvcnkxMjkxMTExMzI=","name":"foosball-app","full_name":"LunarLogic/foosball-app","owner":{"login":"LunarLogic","id":32623,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMyNjIz","avatar_url":"https://avatars3.githubusercontent.com/u/32623?v=4","gravatar_id":"","url":"https://api.github.com/users/LunarLogic","html_url":"https://github.com/LunarLogic","followers_url":"https://api.github.com/users/LunarLogic/followers","following_url":"https://api.github.com/users/LunarLogic/following{/other_user}","gists_url":"https://api.github.com/users/LunarLogic/gists{/gist_id}","starred_url":"https://api.github.com/users/LunarLogic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LunarLogic/subscriptions","organizations_url":"https://api.github.com/users/LunarLogic/orgs","repos_url":"https://api.github.com/users/LunarLogic/repos","events_url":"https://api.github.com/users/LunarLogic/events{/privacy}","received_events_url":"https://api.github.com/users/LunarLogic/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/LunarLogic/foosball-app","description":"Slack bot project for foosball","fork":false,"url":"https://api.github.com/repos/LunarLogic/foosball-app","forks_url":"https://api.github.com/repos/LunarLogic/foosball-app/forks","keys_url":"https://api.github.com/repos/LunarLogic/foosball-app/keys{/key_id}","collaborators_url":"https://api.github.com/repos/LunarLogic/foosball-app/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/LunarLogic/foosball-app/teams","hooks_url":"https://api.github.com/repos/LunarLogic/foosball-app/hooks","issue_events_url":"https://api.github.com/repos/LunarLogic/foosball-app/issues/events{/number}","events_url":"https://api.github.com/repos/LunarLogic/foosball-app/events","assignees_url":"https://api.github.com/repos/LunarLogic/foosball-app/assignees{/user}","branches_url":"https://api.github.com/repos/LunarLogic/foosball-app/branches{/branch}","tags_url":"https://api.github.com/repos/LunarLogic/foosball-app/tags","blobs_url":"https://api.github.com/repos/LunarLogic/foosball-app/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/LunarLogic/foosball-app/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/LunarLogic/foosball-app/git/refs{/sha}","trees_url":"https://api.github.com/repos/LunarLogic/foosball-app/git/trees{/sha}","statuses_url":"https://api.github.com/repos/LunarLogic/foosball-app/statuses/{sha}","languages_url":"https://api.github.com/repos/LunarLogic/foosball-app/languages","stargazers_url":"https://api.github.com/repos/LunarLogic/foosball-app/stargazers","contributors_url":"https://api.github.com/repos/LunarLogic/foosball-app/contributors","subscribers_url":"https://api.github.com/repos/LunarLogic/foosball-app/subscribers","subscription_url":"https://api.github.com/repos/LunarLogic/foosball-app/subscription","commits_url":"https://api.github.com/repos/LunarLogic/foosball-app/commits{/sha}","git_commits_url":"https://api.github.com/repos/LunarLogic/foosball-app/git/commits{/sha}","comments_url":"https://api.github.com/repos/LunarLogic/foosball-app/comments{/number}","issue_comment_url":"https://api.github.com/repos/LunarLogic/foosball-app/issues/comments{/number}","contents_url":"https://api.github.com/repos/LunarLogic/foosball-app/contents/{+path}","compare_url":"https://api.github.com/repos/LunarLogic/foosball-app/compare/{base}...{head}","merges_url":"https://api.github.com/repos/LunarLogic/foosball-app/merges","archive_url":"https://api.github.com/repos/LunarLogic/foosball-app/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/LunarLogic/foosball-app/downloads","issues_url":"https://api.github.com/repos/LunarLogic/foosball-app/issues{/number}","pulls_url":"https://api.github.com/repos/LunarLogic/foosball-app/pulls{/number}","milestones_url":"https://api.github.com/repos/LunarLogic/foosball-app/milestones{/number}","notifications_url":"https://api.github.com/repos/LunarLogic/foosball-app/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/LunarLogic/foosball-app/labels{/name}","releases_url":"https://api.github.com/repos/LunarLogic/foosball-app/releases{/id}","deployments_url":"https://api.github.com/repos/LunarLogic/foosball-app/deployments","created_at":"2018-04-11T14:59:41Z","updated_at":"2018-08-09T08:42:25Z","pushed_at":"2018-08-09T15:26:12Z","git_url":"git://github.com/LunarLogic/foosball-app.git","ssh_url":"git@github.com:LunarLogic/foosball-app.git","clone_url":"https://github.com/LunarLogic/foosball-app.git","svn_url":"https://github.com/LunarLogic/foosball-app","homepage":null,"size":682,"stargazers_count":0,"watchers_count":0,"language":"Ruby","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":3,"license":null,"forks":0,"open_issues":3,"watchers":0,"default_branch":"master"}},"base":{"label":"LunarLogic:master","ref":"master","sha":"c9e263a8464c4845139434abcf10d00cba731fa9","user":{"login":"LunarLogic","id":32623,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMyNjIz","avatar_url":"https://avatars3.githubusercontent.com/u/32623?v=4","gravatar_id":"","url":"https://api.github.com/users/LunarLogic","html_url":"https://github.com/LunarLogic","followers_url":"https://api.github.com/users/LunarLogic/followers","following_url":"https://api.github.com/users/LunarLogic/following{/other_user}","gists_url":"https://api.github.com/users/LunarLogic/gists{/gist_id}","starred_url":"https://api.github.com/users/LunarLogic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LunarLogic/subscriptions","organizations_url":"https://api.github.com/users/LunarLogic/orgs","repos_url":"https://api.github.com/users/LunarLogic/repos","events_url":"https://api.github.com/users/LunarLogic/events{/privacy}","received_events_url":"https://api.github.com/users/LunarLogic/received_events","type":"Organization","site_admin":false},"repo":{"id":129111132,"node_id":"MDEwOlJlcG9zaXRvcnkxMjkxMTExMzI=","name":"foosball-app","full_name":"LunarLogic/foosball-app","owner":{"login":"LunarLogic","id":32623,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMyNjIz","avatar_url":"https://avatars3.githubusercontent.com/u/32623?v=4","gravatar_id":"","url":"https://api.github.com/users/LunarLogic","html_url":"https://github.com/LunarLogic","followers_url":"https://api.github.com/users/LunarLogic/followers","following_url":"https://api.github.com/users/LunarLogic/following{/other_user}","gists_url":"https://api.github.com/users/LunarLogic/gists{/gist_id}","starred_url":"https://api.github.com/users/LunarLogic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LunarLogic/subscriptions","organizations_url":"https://api.github.com/users/LunarLogic/orgs","repos_url":"https://api.github.com/users/LunarLogic/repos","events_url":"https://api.github.com/users/LunarLogic/events{/privacy}","received_events_url":"https://api.github.com/users/LunarLogic/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/LunarLogic/foosball-app","description":"Slack bot project for foosball","fork":false,"url":"https://api.github.com/repos/LunarLogic/foosball-app","forks_url":"https://api.github.com/repos/LunarLogic/foosball-app/forks","keys_url":"https://api.github.com/repos/LunarLogic/foosball-app/keys{/key_id}","collaborators_url":"https://api.github.com/repos/LunarLogic/foosball-app/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/LunarLogic/foosball-app/teams","hooks_url":"https://api.github.com/repos/LunarLogic/foosball-app/hooks","issue_events_url":"https://api.github.com/repos/LunarLogic/foosball-app/issues/events{/number}","events_url":"https://api.github.com/repos/LunarLogic/foosball-app/events","assignees_url":"https://api.github.com/repos/LunarLogic/foosball-app/assignees{/user}","branches_url":"https://api.github.com/repos/LunarLogic/foosball-app/branches{/branch}","tags_url":"https://api.github.com/repos/LunarLogic/foosball-app/tags","blobs_url":"https://api.github.com/repos/LunarLogic/foosball-app/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/LunarLogic/foosball-app/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/LunarLogic/foosball-app/git/refs{/sha}","trees_url":"https://api.github.com/repos/LunarLogic/foosball-app/git/trees{/sha}","statuses_url":"https://api.github.com/repos/LunarLogic/foosball-app/statuses/{sha}","languages_url":"https://api.github.com/repos/LunarLogic/foosball-app/languages","stargazers_url":"https://api.github.com/repos/LunarLogic/foosball-app/stargazers","contributors_url":"https://api.github.com/repos/LunarLogic/foosball-app/contributors","subscribers_url":"https://api.github.com/repos/LunarLogic/foosball-app/subscribers","subscription_url":"https://api.github.com/repos/LunarLogic/foosball-app/subscription","commits_url":"https://api.github.com/repos/LunarLogic/foosball-app/commits{/sha}","git_commits_url":"https://api.github.com/repos/LunarLogic/foosball-app/git/commits{/sha}","comments_url":"https://api.github.com/repos/LunarLogic/foosball-app/comments{/number}","issue_comment_url":"https://api.github.com/repos/LunarLogic/foosball-app/issues/comments{/number}","contents_url":"https://api.github.com/repos/LunarLogic/foosball-app/contents/{+path}","compare_url":"https://api.github.com/repos/LunarLogic/foosball-app/compare/{base}...{head}","merges_url":"https://api.github.com/repos/LunarLogic/foosball-app/merges","archive_url":"https://api.github.com/repos/LunarLogic/foosball-app/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/LunarLogic/foosball-app/downloads","issues_url":"https://api.github.com/repos/LunarLogic/foosball-app/issues{/number}","pulls_url":"https://api.github.com/repos/LunarLogic/foosball-app/pulls{/number}","milestones_url":"https://api.github.com/repos/LunarLogic/foosball-app/milestones{/number}","notifications_url":"https://api.github.com/repos/LunarLogic/foosball-app/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/LunarLogic/foosball-app/labels{/name}","releases_url":"https://api.github.com/repos/LunarLogic/foosball-app/releases{/id}","deployments_url":"https://api.github.com/repos/LunarLogic/foosball-app/deployments","created_at":"2018-04-11T14:59:41Z","updated_at":"2018-08-09T08:42:25Z","pushed_at":"2018-08-09T15:26:12Z","git_url":"git://github.com/LunarLogic/foosball-app.git","ssh_url":"git@github.com:LunarLogic/foosball-app.git","clone_url":"https://github.com/LunarLogic/foosball-app.git","svn_url":"https://github.com/LunarLogic/foosball-app","homepage":null,"size":682,"stargazers_count":0,"watchers_count":0,"language":"Ruby","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":3,"license":null,"forks":0,"open_issues":3,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/LunarLogic/foosball-app/pulls/149"},"html":{"href":"https://github.com/LunarLogic/foosball-app/pull/149"},"issue":{"href":"https://api.github.com/repos/LunarLogic/foosball-app/issues/149"},"comments":{"href":"https://api.github.com/repos/LunarLogic/foosball-app/issues/149/comments"},"review_comments":{"href":"https://api.github.com/repos/LunarLogic/foosball-app/pulls/149/comments"},"review_comment":{"href":"https://api.github.com/repos/LunarLogic/foosball-app/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/LunarLogic/foosball-app/pulls/149/commits"},"statuses":{"href":"https://api.github.com/repos/LunarLogic/foosball-app/statuses/7165c3b17225084f5662cadc4fd652c1a0cad5f0"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"shadre"}}