GitHub PullRequestReviewCommentEvent at 2014-12-25 04:57:51
Repository: utcs-uptime
Actor: jeversmann
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/pulls/comments/22267511","id":22267511,"diff_hunk":"@@ -0,0 +1,98 @@\n+var assert = require('assert');\n+var MongoClient = require('mongodb').MongoClient;\n+var url = 'mongodb://localhost:27017/utcs-uptime';\n+\n+/*\n+ * Replaces the current collection's info on a server\n+ * and stores session data for people who left\n+ */\n+function update (server, w, callback) {\n+  MongoClient.connect(url, function(err, db) {\n+    assert.equal(null, err);\n+    console.log('Updating ' + server);\n+\n+    var current = db.collection('current')\n+      , session = db.collection('session');\n+\n+    current.find({ 'hostname': server }).toArray(\n+      function(err, result) {\n+        assert.equal(null, err);\n+        var oldInfo = result[0];\n+        var nextUsers = [];\n+\n+        if (oldInfo === undefined) {\n+          // Everyone is new\n+          w.forEach(function (user) {\n+            nextUsers.push({\n+              'name': user.USER,\n+              'tty':  user.TTY,\n+              'from': user.FROM,\n+              'time': new Date()\n+            });\n+          });\n+\n+          current.insert({\n+            'hostname': server,\n+            'user-count': nextUsers.length,\n+            'physical': w.some(function (user) { return user.TTY === ':0'; }),\n+            'users': nextUsers\n+          }, function (err, result) {\n+              assert.equal(err, null);\n+              db.close();\n+              callback();\n+            });\n+        } else {\n+          // Retain old users and store sessions for people who left\n+          oldInfo.users.forEach(function (user) {\n+            if (w.some(function (u) { return u.USER === user.name; })) {\n+              nextUsers.push(user);\n+            } else {\n+              session.insert({\n+                'username': user.name,\n+                'servername': server,\n+                'hostname': user.from,\n+                'time': new Date() - user.time,\n+                'physical': user.tty === ':0'\n+              }, function (err, result) {\n+                assert.equal(null, err);\n+                // This connection is closed elsewhere, maybe at an ok time","path":"uptime.js","position":58,"original_position":58,"commit_id":"155403c6d56d2fb15857f94e20ffb5ab13460c5d","original_commit_id":"155403c6d56d2fb15857f94e20ffb5ab13460c5d","user":{"login":"jeversmann","id":3188364,"avatar_url":"https://avatars.githubusercontent.com/u/3188364?v=3","gravatar_id":"","url":"https://api.github.com/users/jeversmann","html_url":"https://github.com/jeversmann","followers_url":"https://api.github.com/users/jeversmann/followers","following_url":"https://api.github.com/users/jeversmann/following{/other_user}","gists_url":"https://api.github.com/users/jeversmann/gists{/gist_id}","starred_url":"https://api.github.com/users/jeversmann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeversmann/subscriptions","organizations_url":"https://api.github.com/users/jeversmann/orgs","repos_url":"https://api.github.com/users/jeversmann/repos","events_url":"https://api.github.com/users/jeversmann/events{/privacy}","received_events_url":"https://api.github.com/users/jeversmann/received_events","type":"User","site_admin":false},"body":"This obviously doesn't work in practice, need to find the right way to do it.","created_at":"2014-12-25T04:57:51Z","updated_at":"2014-12-25T04:57:51Z","html_url":"https://github.com/NosotrosNueces/utcs-uptime/pull/5#discussion_r22267511","pull_request_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/pulls/5","_links":{"self":{"href":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/pulls/comments/22267511"},"html":{"href":"https://github.com/NosotrosNueces/utcs-uptime/pull/5#discussion_r22267511"},"pull_request":{"href":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/pulls/5"}}},"pull_request":{"url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/pulls/5","id":26521944,"html_url":"https://github.com/NosotrosNueces/utcs-uptime/pull/5","diff_url":"https://github.com/NosotrosNueces/utcs-uptime/pull/5.diff","patch_url":"https://github.com/NosotrosNueces/utcs-uptime/pull/5.patch","issue_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/issues/5","number":5,"state":"open","locked":false,"title":"Express time","user":{"login":"jeversmann","id":3188364,"avatar_url":"https://avatars.githubusercontent.com/u/3188364?v=3","gravatar_id":"","url":"https://api.github.com/users/jeversmann","html_url":"https://github.com/jeversmann","followers_url":"https://api.github.com/users/jeversmann/followers","following_url":"https://api.github.com/users/jeversmann/following{/other_user}","gists_url":"https://api.github.com/users/jeversmann/gists{/gist_id}","starred_url":"https://api.github.com/users/jeversmann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeversmann/subscriptions","organizations_url":"https://api.github.com/users/jeversmann/orgs","repos_url":"https://api.github.com/users/jeversmann/repos","events_url":"https://api.github.com/users/jeversmann/events{/privacy}","received_events_url":"https://api.github.com/users/jeversmann/received_events","type":"User","site_admin":false},"body":"This PR contains the changes from mongo-time and express-time.\r\nImports a bunch of project boilerplate for hooking to mongo, seeding dev data, and hosting a simple express site to show uptimes.","created_at":"2014-12-23T17:24:37Z","updated_at":"2014-12-25T04:57:51Z","closed_at":null,"merged_at":null,"merge_commit_sha":"81bfd35a3ecd41c52d33ee343eb6a1b7c942a2f9","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/pulls/5/commits","review_comments_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/pulls/5/comments","review_comment_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/pulls/comments/{number}","comments_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/issues/5/comments","statuses_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/statuses/155403c6d56d2fb15857f94e20ffb5ab13460c5d","head":{"label":"NosotrosNueces:express-time","ref":"express-time","sha":"155403c6d56d2fb15857f94e20ffb5ab13460c5d","user":{"login":"NosotrosNueces","id":8728232,"avatar_url":"https://avatars.githubusercontent.com/u/8728232?v=3","gravatar_id":"","url":"https://api.github.com/users/NosotrosNueces","html_url":"https://github.com/NosotrosNueces","followers_url":"https://api.github.com/users/NosotrosNueces/followers","following_url":"https://api.github.com/users/NosotrosNueces/following{/other_user}","gists_url":"https://api.github.com/users/NosotrosNueces/gists{/gist_id}","starred_url":"https://api.github.com/users/NosotrosNueces/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NosotrosNueces/subscriptions","organizations_url":"https://api.github.com/users/NosotrosNueces/orgs","repos_url":"https://api.github.com/users/NosotrosNueces/repos","events_url":"https://api.github.com/users/NosotrosNueces/events{/privacy}","received_events_url":"https://api.github.com/users/NosotrosNueces/received_events","type":"Organization","site_admin":false},"repo":{"id":28134902,"name":"utcs-uptime","full_name":"NosotrosNueces/utcs-uptime","owner":{"login":"NosotrosNueces","id":8728232,"avatar_url":"https://avatars.githubusercontent.com/u/8728232?v=3","gravatar_id":"","url":"https://api.github.com/users/NosotrosNueces","html_url":"https://github.com/NosotrosNueces","followers_url":"https://api.github.com/users/NosotrosNueces/followers","following_url":"https://api.github.com/users/NosotrosNueces/following{/other_user}","gists_url":"https://api.github.com/users/NosotrosNueces/gists{/gist_id}","starred_url":"https://api.github.com/users/NosotrosNueces/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NosotrosNueces/subscriptions","organizations_url":"https://api.github.com/users/NosotrosNueces/orgs","repos_url":"https://api.github.com/users/NosotrosNueces/repos","events_url":"https://api.github.com/users/NosotrosNueces/events{/privacy}","received_events_url":"https://api.github.com/users/NosotrosNueces/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/NosotrosNueces/utcs-uptime","description":"Let's keep a database of everybody's uptime!","fork":false,"url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime","forks_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/forks","keys_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/keys{/key_id}","collaborators_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/teams","hooks_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/hooks","issue_events_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/issues/events{/number}","events_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/events","assignees_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/assignees{/user}","branches_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/branches{/branch}","tags_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/tags","blobs_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/git/refs{/sha}","trees_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/git/trees{/sha}","statuses_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/statuses/{sha}","languages_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/languages","stargazers_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/stargazers","contributors_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/contributors","subscribers_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/subscribers","subscription_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/subscription","commits_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/commits{/sha}","git_commits_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/git/commits{/sha}","comments_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/comments{/number}","issue_comment_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/issues/comments/{number}","contents_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/contents/{+path}","compare_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/compare/{base}...{head}","merges_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/merges","archive_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/downloads","issues_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/issues{/number}","pulls_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/pulls{/number}","milestones_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/milestones{/number}","notifications_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/labels{/name}","releases_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/releases{/id}","created_at":"2014-12-17T11:44:02Z","updated_at":"2014-12-23T17:22:38Z","pushed_at":"2014-12-25T03:13:42Z","git_url":"git://github.com/NosotrosNueces/utcs-uptime.git","ssh_url":"git@github.com:NosotrosNueces/utcs-uptime.git","clone_url":"https://github.com/NosotrosNueces/utcs-uptime.git","svn_url":"https://github.com/NosotrosNueces/utcs-uptime","homepage":null,"size":276,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":3,"forks":0,"open_issues":3,"watchers":0,"default_branch":"master"}},"base":{"label":"NosotrosNueces:master","ref":"master","sha":"6a1be90d0a6e61fd3b595e6a3850abb688e34e65","user":{"login":"NosotrosNueces","id":8728232,"avatar_url":"https://avatars.githubusercontent.com/u/8728232?v=3","gravatar_id":"","url":"https://api.github.com/users/NosotrosNueces","html_url":"https://github.com/NosotrosNueces","followers_url":"https://api.github.com/users/NosotrosNueces/followers","following_url":"https://api.github.com/users/NosotrosNueces/following{/other_user}","gists_url":"https://api.github.com/users/NosotrosNueces/gists{/gist_id}","starred_url":"https://api.github.com/users/NosotrosNueces/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NosotrosNueces/subscriptions","organizations_url":"https://api.github.com/users/NosotrosNueces/orgs","repos_url":"https://api.github.com/users/NosotrosNueces/repos","events_url":"https://api.github.com/users/NosotrosNueces/events{/privacy}","received_events_url":"https://api.github.com/users/NosotrosNueces/received_events","type":"Organization","site_admin":false},"repo":{"id":28134902,"name":"utcs-uptime","full_name":"NosotrosNueces/utcs-uptime","owner":{"login":"NosotrosNueces","id":8728232,"avatar_url":"https://avatars.githubusercontent.com/u/8728232?v=3","gravatar_id":"","url":"https://api.github.com/users/NosotrosNueces","html_url":"https://github.com/NosotrosNueces","followers_url":"https://api.github.com/users/NosotrosNueces/followers","following_url":"https://api.github.com/users/NosotrosNueces/following{/other_user}","gists_url":"https://api.github.com/users/NosotrosNueces/gists{/gist_id}","starred_url":"https://api.github.com/users/NosotrosNueces/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NosotrosNueces/subscriptions","organizations_url":"https://api.github.com/users/NosotrosNueces/orgs","repos_url":"https://api.github.com/users/NosotrosNueces/repos","events_url":"https://api.github.com/users/NosotrosNueces/events{/privacy}","received_events_url":"https://api.github.com/users/NosotrosNueces/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/NosotrosNueces/utcs-uptime","description":"Let's keep a database of everybody's uptime!","fork":false,"url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime","forks_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/forks","keys_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/keys{/key_id}","collaborators_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/teams","hooks_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/hooks","issue_events_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/issues/events{/number}","events_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/events","assignees_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/assignees{/user}","branches_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/branches{/branch}","tags_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/tags","blobs_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/git/refs{/sha}","trees_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/git/trees{/sha}","statuses_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/statuses/{sha}","languages_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/languages","stargazers_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/stargazers","contributors_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/contributors","subscribers_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/subscribers","subscription_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/subscription","commits_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/commits{/sha}","git_commits_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/git/commits{/sha}","comments_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/comments{/number}","issue_comment_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/issues/comments/{number}","contents_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/contents/{+path}","compare_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/compare/{base}...{head}","merges_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/merges","archive_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/downloads","issues_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/issues{/number}","pulls_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/pulls{/number}","milestones_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/milestones{/number}","notifications_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/labels{/name}","releases_url":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/releases{/id}","created_at":"2014-12-17T11:44:02Z","updated_at":"2014-12-23T17:22:38Z","pushed_at":"2014-12-25T03:13:42Z","git_url":"git://github.com/NosotrosNueces/utcs-uptime.git","ssh_url":"git@github.com:NosotrosNueces/utcs-uptime.git","clone_url":"https://github.com/NosotrosNueces/utcs-uptime.git","svn_url":"https://github.com/NosotrosNueces/utcs-uptime","homepage":null,"size":276,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":3,"forks":0,"open_issues":3,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/pulls/5"},"html":{"href":"https://github.com/NosotrosNueces/utcs-uptime/pull/5"},"issue":{"href":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/issues/5"},"comments":{"href":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/issues/5/comments"},"review_comments":{"href":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/pulls/5/comments"},"review_comment":{"href":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/pulls/5/commits"},"statuses":{"href":"https://api.github.com/repos/NosotrosNueces/utcs-uptime/statuses/155403c6d56d2fb15857f94e20ffb5ab13460c5d"}}}}