{"action":"created","comment":{"url":"https://api.github.com/repos/ndlib/hesburgh_metrics/pulls/comments/63185551","id":63185551,"diff_hunk":"@@ -0,0 +1,114 @@\n+require 'mysql2'\n+require 'ipaddr'\n+\n+# Harvest a Web Logg, and save to mysql\n+#\n+class HarvestWeblogs\n+  @db_connection = nil\n+\n+  #Util Class that parses a single line\n+  class LineRecord\n+    attr_accessor :agent, :event, :event_time, :ip, :method, :path, :pid, :status\n+\n+\n+    # parse the line record\n+    def initialize(line)\n+      fields = line.split(' ')\n+      @ip = fields[0]\n+      @event = nil \n+      @status = fields[9]\n+      @method = fields[6].sub('\"','')\n+      @path = fields[7]\n+      @event_time = DateTime.strptime(fields[3].sub('[',''), \"%d/%b/%Y:%H:%M:%S\")\n+      @pid  = nil\n+      @agent = line\n+    end\n+\n+    # save the record using the active record framework\n+    def save\n+      event = FedoraAccessEvent.new\n+      create_time = DateTime.now\n+      agent_format = agent.split('\"')[5]\n+      event.pid = pid\n+      event.agent = agent_format\n+      event.event = event\n+      event.location = IPAddr.new(ip).mask(24).to_s.split(\"/\")[0]\n+      event.event_time = event_time\n+      event.created_at = create_time\n+      event.updated_at = create_time\n+      event.save","path":"app/services/harvest_weblog.rb","position":39,"original_position":39,"commit_id":"d60218d8506a27790173c4197e0ccfe7516e011c","original_commit_id":"d60218d8506a27790173c4197e0ccfe7516e011c","user":{"login":"msuhovec","id":3360332,"avatar_url":"https://avatars.githubusercontent.com/u/3360332?v=3","gravatar_id":"","url":"https://api.github.com/users/msuhovec","html_url":"https://github.com/msuhovec","followers_url":"https://api.github.com/users/msuhovec/followers","following_url":"https://api.github.com/users/msuhovec/following{/other_user}","gists_url":"https://api.github.com/users/msuhovec/gists{/gist_id}","starred_url":"https://api.github.com/users/msuhovec/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/msuhovec/subscriptions","organizations_url":"https://api.github.com/users/msuhovec/orgs","repos_url":"https://api.github.com/users/msuhovec/repos","events_url":"https://api.github.com/users/msuhovec/events{/privacy}","received_events_url":"https://api.github.com/users/msuhovec/received_events","type":"User","site_admin":false},"body":"I originally raised an exception- Don preferred that I continue on my merry\nway.\n\nOn Fri, May 13, 2016 at 8:32 AM, Jeremy Friesen <notifications@github.com>\nwrote:\n\n> In app/services/harvest_weblog.rb\n> <https://github.com/ndlib/hesburgh_metrics/pull/7#discussion_r63174776>:\n>\n> > +      @agent = line\n> > +    end\n> > +\n> > +    # save the record using the active record framework\n> > +    def save\n> > +      event = FedoraAccessEvent.new\n> > +      create_time = DateTime.now\n> > +      agent_format = agent.split('\"')[5]\n> > +      event.pid = pid\n> > +      event.agent = agent_format\n> > +      event.event = event\n> > +      event.location = IPAddr.new(ip).mask(24).to_s.split(\"/\")[0]\n> > +      event.event_time = event_time\n> > +      event.created_at = create_time\n> > +      event.updated_at = create_time\n> > +      event.save\n>\n> If the record does not save (for some reason) do we want to raise an\n> exception? Or is it okay to move along our merry way?\n>\n> —\n> You are receiving this because you authored the thread.\n> Reply to this email directly or view it on GitHub\n> <https://github.com/ndlib/hesburgh_metrics/pull/7/files/d60218d8506a27790173c4197e0ccfe7516e011c#r63174776>\n>\n","created_at":"2016-05-13T13:50:58Z","updated_at":"2016-05-13T13:50:58Z","html_url":"https://github.com/ndlib/hesburgh_metrics/pull/7#discussion_r63185551","pull_request_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/pulls/7","_links":{"self":{"href":"https://api.github.com/repos/ndlib/hesburgh_metrics/pulls/comments/63185551"},"html":{"href":"https://github.com/ndlib/hesburgh_metrics/pull/7#discussion_r63185551"},"pull_request":{"href":"https://api.github.com/repos/ndlib/hesburgh_metrics/pulls/7"}}},"pull_request":{"url":"https://api.github.com/repos/ndlib/hesburgh_metrics/pulls/7","id":69537152,"html_url":"https://github.com/ndlib/hesburgh_metrics/pull/7","diff_url":"https://github.com/ndlib/hesburgh_metrics/pull/7.diff","patch_url":"https://github.com/ndlib/hesburgh_metrics/pull/7.patch","issue_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/issues/7","number":7,"state":"open","locked":false,"title":"Issue 6","user":{"login":"msuhovec","id":3360332,"avatar_url":"https://avatars.githubusercontent.com/u/3360332?v=3","gravatar_id":"","url":"https://api.github.com/users/msuhovec","html_url":"https://github.com/msuhovec","followers_url":"https://api.github.com/users/msuhovec/followers","following_url":"https://api.github.com/users/msuhovec/following{/other_user}","gists_url":"https://api.github.com/users/msuhovec/gists{/gist_id}","starred_url":"https://api.github.com/users/msuhovec/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/msuhovec/subscriptions","organizations_url":"https://api.github.com/users/msuhovec/orgs","repos_url":"https://api.github.com/users/msuhovec/repos","events_url":"https://api.github.com/users/msuhovec/events{/privacy}","received_events_url":"https://api.github.com/users/msuhovec/received_events","type":"User","site_admin":false},"body":"#6","created_at":"2016-05-10T16:32:13Z","updated_at":"2016-05-13T13:50:58Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d7d109f1e126248ccf4c064903a5a7f7aa83cb5d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/pulls/7/commits","review_comments_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/pulls/7/comments","review_comment_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/issues/7/comments","statuses_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/statuses/d60218d8506a27790173c4197e0ccfe7516e011c","head":{"label":"ndlib:issue-6","ref":"issue-6","sha":"d60218d8506a27790173c4197e0ccfe7516e011c","user":{"login":"ndlib","id":160943,"avatar_url":"https://avatars.githubusercontent.com/u/160943?v=3","gravatar_id":"","url":"https://api.github.com/users/ndlib","html_url":"https://github.com/ndlib","followers_url":"https://api.github.com/users/ndlib/followers","following_url":"https://api.github.com/users/ndlib/following{/other_user}","gists_url":"https://api.github.com/users/ndlib/gists{/gist_id}","starred_url":"https://api.github.com/users/ndlib/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ndlib/subscriptions","organizations_url":"https://api.github.com/users/ndlib/orgs","repos_url":"https://api.github.com/users/ndlib/repos","events_url":"https://api.github.com/users/ndlib/events{/privacy}","received_events_url":"https://api.github.com/users/ndlib/received_events","type":"Organization","site_admin":false},"repo":{"id":57409290,"name":"hesburgh_metrics","full_name":"ndlib/hesburgh_metrics","owner":{"login":"ndlib","id":160943,"avatar_url":"https://avatars.githubusercontent.com/u/160943?v=3","gravatar_id":"","url":"https://api.github.com/users/ndlib","html_url":"https://github.com/ndlib","followers_url":"https://api.github.com/users/ndlib/followers","following_url":"https://api.github.com/users/ndlib/following{/other_user}","gists_url":"https://api.github.com/users/ndlib/gists{/gist_id}","starred_url":"https://api.github.com/users/ndlib/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ndlib/subscriptions","organizations_url":"https://api.github.com/users/ndlib/orgs","repos_url":"https://api.github.com/users/ndlib/repos","events_url":"https://api.github.com/users/ndlib/events{/privacy}","received_events_url":"https://api.github.com/users/ndlib/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ndlib/hesburgh_metrics","description":"","fork":false,"url":"https://api.github.com/repos/ndlib/hesburgh_metrics","forks_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/forks","keys_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/teams","hooks_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/hooks","issue_events_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/issues/events{/number}","events_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/events","assignees_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/assignees{/user}","branches_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/branches{/branch}","tags_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/tags","blobs_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/git/refs{/sha}","trees_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/statuses/{sha}","languages_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/languages","stargazers_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/stargazers","contributors_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/contributors","subscribers_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/subscribers","subscription_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/subscription","commits_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/commits{/sha}","git_commits_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/git/commits{/sha}","comments_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/comments{/number}","issue_comment_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/issues/comments{/number}","contents_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/contents/{+path}","compare_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/merges","archive_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/downloads","issues_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/issues{/number}","pulls_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/pulls{/number}","milestones_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/milestones{/number}","notifications_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/labels{/name}","releases_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/releases{/id}","deployments_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/deployments","created_at":"2016-04-29T19:52:28Z","updated_at":"2016-04-29T19:58:26Z","pushed_at":"2016-05-12T21:02:43Z","git_url":"git://github.com/ndlib/hesburgh_metrics.git","ssh_url":"git@github.com:ndlib/hesburgh_metrics.git","clone_url":"https://github.com/ndlib/hesburgh_metrics.git","svn_url":"https://github.com/ndlib/hesburgh_metrics","homepage":null,"size":50,"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":4,"forks":0,"open_issues":4,"watchers":0,"default_branch":"master"}},"base":{"label":"ndlib:master","ref":"master","sha":"6b7b10aa268f5cf33a58bca18fca00b7ec508b94","user":{"login":"ndlib","id":160943,"avatar_url":"https://avatars.githubusercontent.com/u/160943?v=3","gravatar_id":"","url":"https://api.github.com/users/ndlib","html_url":"https://github.com/ndlib","followers_url":"https://api.github.com/users/ndlib/followers","following_url":"https://api.github.com/users/ndlib/following{/other_user}","gists_url":"https://api.github.com/users/ndlib/gists{/gist_id}","starred_url":"https://api.github.com/users/ndlib/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ndlib/subscriptions","organizations_url":"https://api.github.com/users/ndlib/orgs","repos_url":"https://api.github.com/users/ndlib/repos","events_url":"https://api.github.com/users/ndlib/events{/privacy}","received_events_url":"https://api.github.com/users/ndlib/received_events","type":"Organization","site_admin":false},"repo":{"id":57409290,"name":"hesburgh_metrics","full_name":"ndlib/hesburgh_metrics","owner":{"login":"ndlib","id":160943,"avatar_url":"https://avatars.githubusercontent.com/u/160943?v=3","gravatar_id":"","url":"https://api.github.com/users/ndlib","html_url":"https://github.com/ndlib","followers_url":"https://api.github.com/users/ndlib/followers","following_url":"https://api.github.com/users/ndlib/following{/other_user}","gists_url":"https://api.github.com/users/ndlib/gists{/gist_id}","starred_url":"https://api.github.com/users/ndlib/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ndlib/subscriptions","organizations_url":"https://api.github.com/users/ndlib/orgs","repos_url":"https://api.github.com/users/ndlib/repos","events_url":"https://api.github.com/users/ndlib/events{/privacy}","received_events_url":"https://api.github.com/users/ndlib/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ndlib/hesburgh_metrics","description":"","fork":false,"url":"https://api.github.com/repos/ndlib/hesburgh_metrics","forks_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/forks","keys_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/teams","hooks_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/hooks","issue_events_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/issues/events{/number}","events_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/events","assignees_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/assignees{/user}","branches_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/branches{/branch}","tags_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/tags","blobs_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/git/refs{/sha}","trees_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/statuses/{sha}","languages_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/languages","stargazers_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/stargazers","contributors_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/contributors","subscribers_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/subscribers","subscription_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/subscription","commits_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/commits{/sha}","git_commits_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/git/commits{/sha}","comments_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/comments{/number}","issue_comment_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/issues/comments{/number}","contents_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/contents/{+path}","compare_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/merges","archive_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/downloads","issues_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/issues{/number}","pulls_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/pulls{/number}","milestones_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/milestones{/number}","notifications_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/labels{/name}","releases_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/releases{/id}","deployments_url":"https://api.github.com/repos/ndlib/hesburgh_metrics/deployments","created_at":"2016-04-29T19:52:28Z","updated_at":"2016-04-29T19:58:26Z","pushed_at":"2016-05-12T21:02:43Z","git_url":"git://github.com/ndlib/hesburgh_metrics.git","ssh_url":"git@github.com:ndlib/hesburgh_metrics.git","clone_url":"https://github.com/ndlib/hesburgh_metrics.git","svn_url":"https://github.com/ndlib/hesburgh_metrics","homepage":null,"size":50,"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":4,"forks":0,"open_issues":4,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ndlib/hesburgh_metrics/pulls/7"},"html":{"href":"https://github.com/ndlib/hesburgh_metrics/pull/7"},"issue":{"href":"https://api.github.com/repos/ndlib/hesburgh_metrics/issues/7"},"comments":{"href":"https://api.github.com/repos/ndlib/hesburgh_metrics/issues/7/comments"},"review_comments":{"href":"https://api.github.com/repos/ndlib/hesburgh_metrics/pulls/7/comments"},"review_comment":{"href":"https://api.github.com/repos/ndlib/hesburgh_metrics/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ndlib/hesburgh_metrics/pulls/7/commits"},"statuses":{"href":"https://api.github.com/repos/ndlib/hesburgh_metrics/statuses/d60218d8506a27790173c4197e0ccfe7516e011c"}}}}