{"action":"created","comment":{"url":"https://api.github.com/repos/somenugget/lits-diploma/pulls/comments/87717763","pull_request_review_id":8319377,"id":87717763,"diff_hunk":"@@ -0,0 +1,80 @@\n+require 'byebug'\n+require 'koala'\n+require 'uri'\n+\n+module Components\n+  module EventsReceiver\n+    class FbReceiver < BaseReceiver\n+      TOKEN = 'EAAFXQ51xfCkBADECMbksUKObfcgk7qcajFynAWN55B09ZCAvJIjqrcS1DERTNKRcRYUrQuoBa6oVp5elFfZBVgWLwrL0Q\n+      ZAGB6yUWUreCDEwyOk0p24GpYgH0w5wqZBV1ljf7sjo9v5ZBwUpQ4GKiN1E4pT6yWMIZD'\n+\n+      def initialize\n+        super\n+        @graph = Koala::Facebook::API.new(TOKEN)\n+      end\n+\n+      def save_source_events (source)\n+        events=@graph.get_connections(source.ext_id, 'events')\n+        events.each do |event|\n+\n+          event = get_event event\n+          event[:source_id] = source.id\n+          event[:city_id] = source.city_id\n+\n+          event_in_db = Event.fb_source.find_by(ext_id: event[:ext_id].to_i)\n+          save_key = :updated\n+\n+          if event_in_db.nil?\n+            save_key = :created\n+            event_in_db = Event.new event\n+          end\n+\n+          if event_in_db.save\n+            @report[save_key] += 1\n+          else\n+            puts event_in_db.errors.full_messages\n+            @report[:errors] += 1\n+          end\n+\n+          break if event[:date] < DateTime.now\n+        end\n+      end\n+\n+      def get_event (event)\n+        process_data(event)\n+      end\n+\n+      def process_data(event)\n+\n+\n+        puts raw_event = {}\n+        puts raw_event['name'] = event['name']","path":"lits/lib/components/events_receiver/fb_receiver.rb","position":null,"original_position":51,"commit_id":"3ed638513679253ad4b5aa209141d98a78997eb2","original_commit_id":"f7e04a7dc5869b9500d5999aee6d567d531275e8","user":{"login":"Slippyjohny","id":21005004,"avatar_url":"https://avatars.githubusercontent.com/u/21005004?v=3","gravatar_id":"","url":"https://api.github.com/users/Slippyjohny","html_url":"https://github.com/Slippyjohny","followers_url":"https://api.github.com/users/Slippyjohny/followers","following_url":"https://api.github.com/users/Slippyjohny/following{/other_user}","gists_url":"https://api.github.com/users/Slippyjohny/gists{/gist_id}","starred_url":"https://api.github.com/users/Slippyjohny/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Slippyjohny/subscriptions","organizations_url":"https://api.github.com/users/Slippyjohny/orgs","repos_url":"https://api.github.com/users/Slippyjohny/repos","events_url":"https://api.github.com/users/Slippyjohny/events{/privacy}","received_events_url":"https://api.github.com/users/Slippyjohny/received_events","type":"User","site_admin":false},"body":"короче пускай всё так и остается\r\n","created_at":"2016-11-13T18:09:38Z","updated_at":"2016-11-13T18:09:38Z","html_url":"https://github.com/somenugget/lits-diploma/pull/15#discussion_r87717763","pull_request_url":"https://api.github.com/repos/somenugget/lits-diploma/pulls/15","_links":{"self":{"href":"https://api.github.com/repos/somenugget/lits-diploma/pulls/comments/87717763"},"html":{"href":"https://github.com/somenugget/lits-diploma/pull/15#discussion_r87717763"},"pull_request":{"href":"https://api.github.com/repos/somenugget/lits-diploma/pulls/15"}}},"pull_request":{"url":"https://api.github.com/repos/somenugget/lits-diploma/pulls/15","id":93478214,"html_url":"https://github.com/somenugget/lits-diploma/pull/15","diff_url":"https://github.com/somenugget/lits-diploma/pull/15.diff","patch_url":"https://github.com/somenugget/lits-diploma/pull/15.patch","issue_url":"https://api.github.com/repos/somenugget/lits-diploma/issues/15","number":15,"state":"open","locked":false,"title":"Fetching FB events","user":{"login":"somenugget","id":9462185,"avatar_url":"https://avatars.githubusercontent.com/u/9462185?v=3","gravatar_id":"","url":"https://api.github.com/users/somenugget","html_url":"https://github.com/somenugget","followers_url":"https://api.github.com/users/somenugget/followers","following_url":"https://api.github.com/users/somenugget/following{/other_user}","gists_url":"https://api.github.com/users/somenugget/gists{/gist_id}","starred_url":"https://api.github.com/users/somenugget/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/somenugget/subscriptions","organizations_url":"https://api.github.com/users/somenugget/orgs","repos_url":"https://api.github.com/users/somenugget/repos","events_url":"https://api.github.com/users/somenugget/events{/privacy}","received_events_url":"https://api.github.com/users/somenugget/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-11-13T16:38:39Z","updated_at":"2016-11-13T18:09:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3c6d03c982bfb3c5db7b2e5faea7b4d08e274774","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/somenugget/lits-diploma/pulls/15/commits","review_comments_url":"https://api.github.com/repos/somenugget/lits-diploma/pulls/15/comments","review_comment_url":"https://api.github.com/repos/somenugget/lits-diploma/pulls/comments{/number}","comments_url":"https://api.github.com/repos/somenugget/lits-diploma/issues/15/comments","statuses_url":"https://api.github.com/repos/somenugget/lits-diploma/statuses/3ed638513679253ad4b5aa209141d98a78997eb2","head":{"label":"somenugget:SlippyJohny","ref":"SlippyJohny","sha":"3ed638513679253ad4b5aa209141d98a78997eb2","user":{"login":"somenugget","id":9462185,"avatar_url":"https://avatars.githubusercontent.com/u/9462185?v=3","gravatar_id":"","url":"https://api.github.com/users/somenugget","html_url":"https://github.com/somenugget","followers_url":"https://api.github.com/users/somenugget/followers","following_url":"https://api.github.com/users/somenugget/following{/other_user}","gists_url":"https://api.github.com/users/somenugget/gists{/gist_id}","starred_url":"https://api.github.com/users/somenugget/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/somenugget/subscriptions","organizations_url":"https://api.github.com/users/somenugget/orgs","repos_url":"https://api.github.com/users/somenugget/repos","events_url":"https://api.github.com/users/somenugget/events{/privacy}","received_events_url":"https://api.github.com/users/somenugget/received_events","type":"User","site_admin":false},"repo":{"id":71624783,"name":"lits-diploma","full_name":"somenugget/lits-diploma","owner":{"login":"somenugget","id":9462185,"avatar_url":"https://avatars.githubusercontent.com/u/9462185?v=3","gravatar_id":"","url":"https://api.github.com/users/somenugget","html_url":"https://github.com/somenugget","followers_url":"https://api.github.com/users/somenugget/followers","following_url":"https://api.github.com/users/somenugget/following{/other_user}","gists_url":"https://api.github.com/users/somenugget/gists{/gist_id}","starred_url":"https://api.github.com/users/somenugget/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/somenugget/subscriptions","organizations_url":"https://api.github.com/users/somenugget/orgs","repos_url":"https://api.github.com/users/somenugget/repos","events_url":"https://api.github.com/users/somenugget/events{/privacy}","received_events_url":"https://api.github.com/users/somenugget/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/somenugget/lits-diploma","description":"Diploma for LITS Ruby on Rails course","fork":false,"url":"https://api.github.com/repos/somenugget/lits-diploma","forks_url":"https://api.github.com/repos/somenugget/lits-diploma/forks","keys_url":"https://api.github.com/repos/somenugget/lits-diploma/keys{/key_id}","collaborators_url":"https://api.github.com/repos/somenugget/lits-diploma/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/somenugget/lits-diploma/teams","hooks_url":"https://api.github.com/repos/somenugget/lits-diploma/hooks","issue_events_url":"https://api.github.com/repos/somenugget/lits-diploma/issues/events{/number}","events_url":"https://api.github.com/repos/somenugget/lits-diploma/events","assignees_url":"https://api.github.com/repos/somenugget/lits-diploma/assignees{/user}","branches_url":"https://api.github.com/repos/somenugget/lits-diploma/branches{/branch}","tags_url":"https://api.github.com/repos/somenugget/lits-diploma/tags","blobs_url":"https://api.github.com/repos/somenugget/lits-diploma/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/somenugget/lits-diploma/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/somenugget/lits-diploma/git/refs{/sha}","trees_url":"https://api.github.com/repos/somenugget/lits-diploma/git/trees{/sha}","statuses_url":"https://api.github.com/repos/somenugget/lits-diploma/statuses/{sha}","languages_url":"https://api.github.com/repos/somenugget/lits-diploma/languages","stargazers_url":"https://api.github.com/repos/somenugget/lits-diploma/stargazers","contributors_url":"https://api.github.com/repos/somenugget/lits-diploma/contributors","subscribers_url":"https://api.github.com/repos/somenugget/lits-diploma/subscribers","subscription_url":"https://api.github.com/repos/somenugget/lits-diploma/subscription","commits_url":"https://api.github.com/repos/somenugget/lits-diploma/commits{/sha}","git_commits_url":"https://api.github.com/repos/somenugget/lits-diploma/git/commits{/sha}","comments_url":"https://api.github.com/repos/somenugget/lits-diploma/comments{/number}","issue_comment_url":"https://api.github.com/repos/somenugget/lits-diploma/issues/comments{/number}","contents_url":"https://api.github.com/repos/somenugget/lits-diploma/contents/{+path}","compare_url":"https://api.github.com/repos/somenugget/lits-diploma/compare/{base}...{head}","merges_url":"https://api.github.com/repos/somenugget/lits-diploma/merges","archive_url":"https://api.github.com/repos/somenugget/lits-diploma/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/somenugget/lits-diploma/downloads","issues_url":"https://api.github.com/repos/somenugget/lits-diploma/issues{/number}","pulls_url":"https://api.github.com/repos/somenugget/lits-diploma/pulls{/number}","milestones_url":"https://api.github.com/repos/somenugget/lits-diploma/milestones{/number}","notifications_url":"https://api.github.com/repos/somenugget/lits-diploma/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/somenugget/lits-diploma/labels{/name}","releases_url":"https://api.github.com/repos/somenugget/lits-diploma/releases{/id}","deployments_url":"https://api.github.com/repos/somenugget/lits-diploma/deployments","created_at":"2016-10-22T07:47:41Z","updated_at":"2016-11-04T08:27:10Z","pushed_at":"2016-11-13T17:51:32Z","git_url":"git://github.com/somenugget/lits-diploma.git","ssh_url":"git@github.com:somenugget/lits-diploma.git","clone_url":"https://github.com/somenugget/lits-diploma.git","svn_url":"https://github.com/somenugget/lits-diploma","homepage":null,"size":1839,"stargazers_count":2,"watchers_count":2,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":2,"forks":1,"open_issues":2,"watchers":2,"default_branch":"master"}},"base":{"label":"somenugget:master","ref":"master","sha":"bd0fa24b62d0b71507a123f2cbd24a3f8acf380d","user":{"login":"somenugget","id":9462185,"avatar_url":"https://avatars.githubusercontent.com/u/9462185?v=3","gravatar_id":"","url":"https://api.github.com/users/somenugget","html_url":"https://github.com/somenugget","followers_url":"https://api.github.com/users/somenugget/followers","following_url":"https://api.github.com/users/somenugget/following{/other_user}","gists_url":"https://api.github.com/users/somenugget/gists{/gist_id}","starred_url":"https://api.github.com/users/somenugget/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/somenugget/subscriptions","organizations_url":"https://api.github.com/users/somenugget/orgs","repos_url":"https://api.github.com/users/somenugget/repos","events_url":"https://api.github.com/users/somenugget/events{/privacy}","received_events_url":"https://api.github.com/users/somenugget/received_events","type":"User","site_admin":false},"repo":{"id":71624783,"name":"lits-diploma","full_name":"somenugget/lits-diploma","owner":{"login":"somenugget","id":9462185,"avatar_url":"https://avatars.githubusercontent.com/u/9462185?v=3","gravatar_id":"","url":"https://api.github.com/users/somenugget","html_url":"https://github.com/somenugget","followers_url":"https://api.github.com/users/somenugget/followers","following_url":"https://api.github.com/users/somenugget/following{/other_user}","gists_url":"https://api.github.com/users/somenugget/gists{/gist_id}","starred_url":"https://api.github.com/users/somenugget/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/somenugget/subscriptions","organizations_url":"https://api.github.com/users/somenugget/orgs","repos_url":"https://api.github.com/users/somenugget/repos","events_url":"https://api.github.com/users/somenugget/events{/privacy}","received_events_url":"https://api.github.com/users/somenugget/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/somenugget/lits-diploma","description":"Diploma for LITS Ruby on Rails course","fork":false,"url":"https://api.github.com/repos/somenugget/lits-diploma","forks_url":"https://api.github.com/repos/somenugget/lits-diploma/forks","keys_url":"https://api.github.com/repos/somenugget/lits-diploma/keys{/key_id}","collaborators_url":"https://api.github.com/repos/somenugget/lits-diploma/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/somenugget/lits-diploma/teams","hooks_url":"https://api.github.com/repos/somenugget/lits-diploma/hooks","issue_events_url":"https://api.github.com/repos/somenugget/lits-diploma/issues/events{/number}","events_url":"https://api.github.com/repos/somenugget/lits-diploma/events","assignees_url":"https://api.github.com/repos/somenugget/lits-diploma/assignees{/user}","branches_url":"https://api.github.com/repos/somenugget/lits-diploma/branches{/branch}","tags_url":"https://api.github.com/repos/somenugget/lits-diploma/tags","blobs_url":"https://api.github.com/repos/somenugget/lits-diploma/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/somenugget/lits-diploma/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/somenugget/lits-diploma/git/refs{/sha}","trees_url":"https://api.github.com/repos/somenugget/lits-diploma/git/trees{/sha}","statuses_url":"https://api.github.com/repos/somenugget/lits-diploma/statuses/{sha}","languages_url":"https://api.github.com/repos/somenugget/lits-diploma/languages","stargazers_url":"https://api.github.com/repos/somenugget/lits-diploma/stargazers","contributors_url":"https://api.github.com/repos/somenugget/lits-diploma/contributors","subscribers_url":"https://api.github.com/repos/somenugget/lits-diploma/subscribers","subscription_url":"https://api.github.com/repos/somenugget/lits-diploma/subscription","commits_url":"https://api.github.com/repos/somenugget/lits-diploma/commits{/sha}","git_commits_url":"https://api.github.com/repos/somenugget/lits-diploma/git/commits{/sha}","comments_url":"https://api.github.com/repos/somenugget/lits-diploma/comments{/number}","issue_comment_url":"https://api.github.com/repos/somenugget/lits-diploma/issues/comments{/number}","contents_url":"https://api.github.com/repos/somenugget/lits-diploma/contents/{+path}","compare_url":"https://api.github.com/repos/somenugget/lits-diploma/compare/{base}...{head}","merges_url":"https://api.github.com/repos/somenugget/lits-diploma/merges","archive_url":"https://api.github.com/repos/somenugget/lits-diploma/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/somenugget/lits-diploma/downloads","issues_url":"https://api.github.com/repos/somenugget/lits-diploma/issues{/number}","pulls_url":"https://api.github.com/repos/somenugget/lits-diploma/pulls{/number}","milestones_url":"https://api.github.com/repos/somenugget/lits-diploma/milestones{/number}","notifications_url":"https://api.github.com/repos/somenugget/lits-diploma/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/somenugget/lits-diploma/labels{/name}","releases_url":"https://api.github.com/repos/somenugget/lits-diploma/releases{/id}","deployments_url":"https://api.github.com/repos/somenugget/lits-diploma/deployments","created_at":"2016-10-22T07:47:41Z","updated_at":"2016-11-04T08:27:10Z","pushed_at":"2016-11-13T17:51:32Z","git_url":"git://github.com/somenugget/lits-diploma.git","ssh_url":"git@github.com:somenugget/lits-diploma.git","clone_url":"https://github.com/somenugget/lits-diploma.git","svn_url":"https://github.com/somenugget/lits-diploma","homepage":null,"size":1839,"stargazers_count":2,"watchers_count":2,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":2,"forks":1,"open_issues":2,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/somenugget/lits-diploma/pulls/15"},"html":{"href":"https://github.com/somenugget/lits-diploma/pull/15"},"issue":{"href":"https://api.github.com/repos/somenugget/lits-diploma/issues/15"},"comments":{"href":"https://api.github.com/repos/somenugget/lits-diploma/issues/15/comments"},"review_comments":{"href":"https://api.github.com/repos/somenugget/lits-diploma/pulls/15/comments"},"review_comment":{"href":"https://api.github.com/repos/somenugget/lits-diploma/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/somenugget/lits-diploma/pulls/15/commits"},"statuses":{"href":"https://api.github.com/repos/somenugget/lits-diploma/statuses/3ed638513679253ad4b5aa209141d98a78997eb2"}}}}
{"actor":{"display_login":"Slippyjohny"}}