{"action":"created","comment":{"url":"https://api.github.com/repos/ViDA-NYU/genotet/pulls/comments/57755385","id":57755385,"diff_hunk":"@@ -0,0 +1,182 @@\n+/**\n+ * @fileoverview database access object for data.\n+ */\n+\n+var mongodb = require('mongodb');\n+var MongoClient = mongodb.MongoClient;\n+var mongoUrl = 'mongodb://localhost:27017/express';\n+\n+var log = require('./log');\n+\n+/** @type {dbData} */\n+module.exports = dbData;\n+\n+/**\n+ * @constructor\n+ */\n+function dbData() {}\n+\n+/**\n+ * @private @const {string}\n+ */\n+dbData.DATA_COLLECTION_ = 'file';\n+\n+/**\n+ * @private @const {string}\n+ */\n+dbData.PROGRESS_COLLECTION_ = 'uploadProgress';\n+\n+/**\n+ * @private @type {string}\n+ */\n+dbData.USERNAME_ = 'anonymous';\n+\n+/**\n+ * @typedef {{\n+ *   error: string\n+ * }}\n+ */\n+dbData.Error;\n+\n+/**\n+ * Creates a connection to the mongodb.\n+ * @param {function(!mongodb.Db, Object=)} callback The callback function.\n+ */\n+dbData.createConnection = function(callback) {\n+  MongoClient.connect(mongoUrl, function(err, db) {\n+    callback(db, err);\n+  });\n+};\n+\n+/**\n+ * Inserts a new file into database.\n+ * @param {!mongodb.Db} db The database.\n+ * @param {string} path Path to the folder of the file.\n+ * @param {string} fileName File name of the file.\n+ * @param {!Object} property Properties of the file.\n+ * @param {function(Object)} callback Callback function.\n+ */\n+dbData.insertFile = function(db, path, fileName, property, callback) {\n+  var collection = db.collection(dbData.DATA_COLLECTION_);\n+  collection.insertOne({\n+    fileName: fileName,\n+    path: path,\n+    property: property,\n+    user: dbData.USERNAME_\n+  }, function(err, result) {\n+    if (err) {\n+      log.serverLog(err);\n+      callback({error: err});\n+    }\n+    log.serverLog(result);\n+  });\n+\n+  collection = db.collection(dbData.PROGRESS_COLLECTION_);\n+  collection.insertOne({\n+    fileName: fileName,\n+    user: dbData.USERNAME_,\n+    percentage: 0\n+  }, function(err, result) {\n+    if (err) {\n+      log.serverLog(err);\n+      callback({error: err});\n+    }\n+    log.serverLog(result);\n+    callback({});\n+  });\n+};\n+\n+/**\n+ * Updates processing progress in database.\n+ * @param {!mongodb.Db} db The database.\n+ * @param {string} fileName File name of the file.\n+ * @param {number} percentage Processing progress percentage.\n+ * @param {function(Object)} callback Callback function.\n+ */\n+dbData.updateProgress = function(db, fileName, percentage, callback) {\n+  var collection = db.collection(dbData.PROGRESS_COLLECTION_);\n+  collection.updateOne({fileName: fileName},\n+    {$set: {percentage: percentage}}, function(err, result) {\n+      if (err) {","path":"server/dbData.js","position":100,"original_position":100,"commit_id":"9bf18c42de0b0a3d3a85570c721d72c18adb44ca","original_commit_id":"9bf18c42de0b0a3d3a85570c721d72c18adb44ca","user":{"login":"djasmine","id":1571174,"avatar_url":"https://avatars.githubusercontent.com/u/1571174?v=3","gravatar_id":"","url":"https://api.github.com/users/djasmine","html_url":"https://github.com/djasmine","followers_url":"https://api.github.com/users/djasmine/followers","following_url":"https://api.github.com/users/djasmine/following{/other_user}","gists_url":"https://api.github.com/users/djasmine/gists{/gist_id}","starred_url":"https://api.github.com/users/djasmine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/djasmine/subscriptions","organizations_url":"https://api.github.com/users/djasmine/orgs","repos_url":"https://api.github.com/users/djasmine/repos","events_url":"https://api.github.com/users/djasmine/events{/privacy}","received_events_url":"https://api.github.com/users/djasmine/received_events","type":"User","site_admin":false},"body":"It seems we should immediately return when error occurs, then we should estimate err again outside this function.","created_at":"2016-03-29T16:35:56Z","updated_at":"2016-03-29T16:35:56Z","html_url":"https://github.com/ViDA-NYU/genotet/pull/158#discussion_r57755385","pull_request_url":"https://api.github.com/repos/ViDA-NYU/genotet/pulls/158","_links":{"self":{"href":"https://api.github.com/repos/ViDA-NYU/genotet/pulls/comments/57755385"},"html":{"href":"https://github.com/ViDA-NYU/genotet/pull/158#discussion_r57755385"},"pull_request":{"href":"https://api.github.com/repos/ViDA-NYU/genotet/pulls/158"}}},"pull_request":{"url":"https://api.github.com/repos/ViDA-NYU/genotet/pulls/158","id":64205020,"html_url":"https://github.com/ViDA-NYU/genotet/pull/158","diff_url":"https://github.com/ViDA-NYU/genotet/pull/158.diff","patch_url":"https://github.com/ViDA-NYU/genotet/pull/158.patch","issue_url":"https://api.github.com/repos/ViDA-NYU/genotet/issues/158","number":158,"state":"open","locked":false,"title":"Real progress bar for data processing","user":{"login":"djasmine","id":1571174,"avatar_url":"https://avatars.githubusercontent.com/u/1571174?v=3","gravatar_id":"","url":"https://api.github.com/users/djasmine","html_url":"https://github.com/djasmine","followers_url":"https://api.github.com/users/djasmine/followers","following_url":"https://api.github.com/users/djasmine/following{/other_user}","gists_url":"https://api.github.com/users/djasmine/gists{/gist_id}","starred_url":"https://api.github.com/users/djasmine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/djasmine/subscriptions","organizations_url":"https://api.github.com/users/djasmine/orgs","repos_url":"https://api.github.com/users/djasmine/repos","events_url":"https://api.github.com/users/djasmine/events{/privacy}","received_events_url":"https://api.github.com/users/djasmine/received_events","type":"User","site_admin":false},"body":"Add progress.php for progress monitoring.\r\nUse data reading part for main progress proportion.\r\n","created_at":"2016-03-25T20:39:46Z","updated_at":"2016-03-29T16:35:56Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8bf8c9949626119e01cbd53ed3fbb24b66421dd6","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ViDA-NYU/genotet/pulls/158/commits","review_comments_url":"https://api.github.com/repos/ViDA-NYU/genotet/pulls/158/comments","review_comment_url":"https://api.github.com/repos/ViDA-NYU/genotet/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ViDA-NYU/genotet/issues/158/comments","statuses_url":"https://api.github.com/repos/ViDA-NYU/genotet/statuses/9bf18c42de0b0a3d3a85570c721d72c18adb44ca","head":{"label":"ViDA-NYU:jdong","ref":"jdong","sha":"9bf18c42de0b0a3d3a85570c721d72c18adb44ca","user":{"login":"ViDA-NYU","id":8114708,"avatar_url":"https://avatars.githubusercontent.com/u/8114708?v=3","gravatar_id":"","url":"https://api.github.com/users/ViDA-NYU","html_url":"https://github.com/ViDA-NYU","followers_url":"https://api.github.com/users/ViDA-NYU/followers","following_url":"https://api.github.com/users/ViDA-NYU/following{/other_user}","gists_url":"https://api.github.com/users/ViDA-NYU/gists{/gist_id}","starred_url":"https://api.github.com/users/ViDA-NYU/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ViDA-NYU/subscriptions","organizations_url":"https://api.github.com/users/ViDA-NYU/orgs","repos_url":"https://api.github.com/users/ViDA-NYU/repos","events_url":"https://api.github.com/users/ViDA-NYU/events{/privacy}","received_events_url":"https://api.github.com/users/ViDA-NYU/received_events","type":"Organization","site_admin":false},"repo":{"id":24764416,"name":"genotet","full_name":"ViDA-NYU/genotet","owner":{"login":"ViDA-NYU","id":8114708,"avatar_url":"https://avatars.githubusercontent.com/u/8114708?v=3","gravatar_id":"","url":"https://api.github.com/users/ViDA-NYU","html_url":"https://github.com/ViDA-NYU","followers_url":"https://api.github.com/users/ViDA-NYU/followers","following_url":"https://api.github.com/users/ViDA-NYU/following{/other_user}","gists_url":"https://api.github.com/users/ViDA-NYU/gists{/gist_id}","starred_url":"https://api.github.com/users/ViDA-NYU/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ViDA-NYU/subscriptions","organizations_url":"https://api.github.com/users/ViDA-NYU/orgs","repos_url":"https://api.github.com/users/ViDA-NYU/repos","events_url":"https://api.github.com/users/ViDA-NYU/events{/privacy}","received_events_url":"https://api.github.com/users/ViDA-NYU/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ViDA-NYU/genotet","description":"Genotet: An Interactive Web-based Visual Exploration Framework to Support Validation of Gene Regulatory Networks","fork":false,"url":"https://api.github.com/repos/ViDA-NYU/genotet","forks_url":"https://api.github.com/repos/ViDA-NYU/genotet/forks","keys_url":"https://api.github.com/repos/ViDA-NYU/genotet/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ViDA-NYU/genotet/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ViDA-NYU/genotet/teams","hooks_url":"https://api.github.com/repos/ViDA-NYU/genotet/hooks","issue_events_url":"https://api.github.com/repos/ViDA-NYU/genotet/issues/events{/number}","events_url":"https://api.github.com/repos/ViDA-NYU/genotet/events","assignees_url":"https://api.github.com/repos/ViDA-NYU/genotet/assignees{/user}","branches_url":"https://api.github.com/repos/ViDA-NYU/genotet/branches{/branch}","tags_url":"https://api.github.com/repos/ViDA-NYU/genotet/tags","blobs_url":"https://api.github.com/repos/ViDA-NYU/genotet/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ViDA-NYU/genotet/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ViDA-NYU/genotet/git/refs{/sha}","trees_url":"https://api.github.com/repos/ViDA-NYU/genotet/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ViDA-NYU/genotet/statuses/{sha}","languages_url":"https://api.github.com/repos/ViDA-NYU/genotet/languages","stargazers_url":"https://api.github.com/repos/ViDA-NYU/genotet/stargazers","contributors_url":"https://api.github.com/repos/ViDA-NYU/genotet/contributors","subscribers_url":"https://api.github.com/repos/ViDA-NYU/genotet/subscribers","subscription_url":"https://api.github.com/repos/ViDA-NYU/genotet/subscription","commits_url":"https://api.github.com/repos/ViDA-NYU/genotet/commits{/sha}","git_commits_url":"https://api.github.com/repos/ViDA-NYU/genotet/git/commits{/sha}","comments_url":"https://api.github.com/repos/ViDA-NYU/genotet/comments{/number}","issue_comment_url":"https://api.github.com/repos/ViDA-NYU/genotet/issues/comments{/number}","contents_url":"https://api.github.com/repos/ViDA-NYU/genotet/contents/{+path}","compare_url":"https://api.github.com/repos/ViDA-NYU/genotet/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ViDA-NYU/genotet/merges","archive_url":"https://api.github.com/repos/ViDA-NYU/genotet/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ViDA-NYU/genotet/downloads","issues_url":"https://api.github.com/repos/ViDA-NYU/genotet/issues{/number}","pulls_url":"https://api.github.com/repos/ViDA-NYU/genotet/pulls{/number}","milestones_url":"https://api.github.com/repos/ViDA-NYU/genotet/milestones{/number}","notifications_url":"https://api.github.com/repos/ViDA-NYU/genotet/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ViDA-NYU/genotet/labels{/name}","releases_url":"https://api.github.com/repos/ViDA-NYU/genotet/releases{/id}","deployments_url":"https://api.github.com/repos/ViDA-NYU/genotet/deployments","created_at":"2014-10-03T15:55:16Z","updated_at":"2016-02-23T03:11:39Z","pushed_at":"2016-03-29T14:28:44Z","git_url":"git://github.com/ViDA-NYU/genotet.git","ssh_url":"git@github.com:ViDA-NYU/genotet.git","clone_url":"https://github.com/ViDA-NYU/genotet.git","svn_url":"https://github.com/ViDA-NYU/genotet","homepage":null,"size":2044,"stargazers_count":5,"watchers_count":5,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":29,"forks":5,"open_issues":29,"watchers":5,"default_branch":"refactor"}},"base":{"label":"ViDA-NYU:refactor","ref":"refactor","sha":"e2005dd94bfd1ee6f7a8c47cfd164b75e40e4802","user":{"login":"ViDA-NYU","id":8114708,"avatar_url":"https://avatars.githubusercontent.com/u/8114708?v=3","gravatar_id":"","url":"https://api.github.com/users/ViDA-NYU","html_url":"https://github.com/ViDA-NYU","followers_url":"https://api.github.com/users/ViDA-NYU/followers","following_url":"https://api.github.com/users/ViDA-NYU/following{/other_user}","gists_url":"https://api.github.com/users/ViDA-NYU/gists{/gist_id}","starred_url":"https://api.github.com/users/ViDA-NYU/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ViDA-NYU/subscriptions","organizations_url":"https://api.github.com/users/ViDA-NYU/orgs","repos_url":"https://api.github.com/users/ViDA-NYU/repos","events_url":"https://api.github.com/users/ViDA-NYU/events{/privacy}","received_events_url":"https://api.github.com/users/ViDA-NYU/received_events","type":"Organization","site_admin":false},"repo":{"id":24764416,"name":"genotet","full_name":"ViDA-NYU/genotet","owner":{"login":"ViDA-NYU","id":8114708,"avatar_url":"https://avatars.githubusercontent.com/u/8114708?v=3","gravatar_id":"","url":"https://api.github.com/users/ViDA-NYU","html_url":"https://github.com/ViDA-NYU","followers_url":"https://api.github.com/users/ViDA-NYU/followers","following_url":"https://api.github.com/users/ViDA-NYU/following{/other_user}","gists_url":"https://api.github.com/users/ViDA-NYU/gists{/gist_id}","starred_url":"https://api.github.com/users/ViDA-NYU/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ViDA-NYU/subscriptions","organizations_url":"https://api.github.com/users/ViDA-NYU/orgs","repos_url":"https://api.github.com/users/ViDA-NYU/repos","events_url":"https://api.github.com/users/ViDA-NYU/events{/privacy}","received_events_url":"https://api.github.com/users/ViDA-NYU/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ViDA-NYU/genotet","description":"Genotet: An Interactive Web-based Visual Exploration Framework to Support Validation of Gene Regulatory Networks","fork":false,"url":"https://api.github.com/repos/ViDA-NYU/genotet","forks_url":"https://api.github.com/repos/ViDA-NYU/genotet/forks","keys_url":"https://api.github.com/repos/ViDA-NYU/genotet/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ViDA-NYU/genotet/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ViDA-NYU/genotet/teams","hooks_url":"https://api.github.com/repos/ViDA-NYU/genotet/hooks","issue_events_url":"https://api.github.com/repos/ViDA-NYU/genotet/issues/events{/number}","events_url":"https://api.github.com/repos/ViDA-NYU/genotet/events","assignees_url":"https://api.github.com/repos/ViDA-NYU/genotet/assignees{/user}","branches_url":"https://api.github.com/repos/ViDA-NYU/genotet/branches{/branch}","tags_url":"https://api.github.com/repos/ViDA-NYU/genotet/tags","blobs_url":"https://api.github.com/repos/ViDA-NYU/genotet/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ViDA-NYU/genotet/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ViDA-NYU/genotet/git/refs{/sha}","trees_url":"https://api.github.com/repos/ViDA-NYU/genotet/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ViDA-NYU/genotet/statuses/{sha}","languages_url":"https://api.github.com/repos/ViDA-NYU/genotet/languages","stargazers_url":"https://api.github.com/repos/ViDA-NYU/genotet/stargazers","contributors_url":"https://api.github.com/repos/ViDA-NYU/genotet/contributors","subscribers_url":"https://api.github.com/repos/ViDA-NYU/genotet/subscribers","subscription_url":"https://api.github.com/repos/ViDA-NYU/genotet/subscription","commits_url":"https://api.github.com/repos/ViDA-NYU/genotet/commits{/sha}","git_commits_url":"https://api.github.com/repos/ViDA-NYU/genotet/git/commits{/sha}","comments_url":"https://api.github.com/repos/ViDA-NYU/genotet/comments{/number}","issue_comment_url":"https://api.github.com/repos/ViDA-NYU/genotet/issues/comments{/number}","contents_url":"https://api.github.com/repos/ViDA-NYU/genotet/contents/{+path}","compare_url":"https://api.github.com/repos/ViDA-NYU/genotet/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ViDA-NYU/genotet/merges","archive_url":"https://api.github.com/repos/ViDA-NYU/genotet/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ViDA-NYU/genotet/downloads","issues_url":"https://api.github.com/repos/ViDA-NYU/genotet/issues{/number}","pulls_url":"https://api.github.com/repos/ViDA-NYU/genotet/pulls{/number}","milestones_url":"https://api.github.com/repos/ViDA-NYU/genotet/milestones{/number}","notifications_url":"https://api.github.com/repos/ViDA-NYU/genotet/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ViDA-NYU/genotet/labels{/name}","releases_url":"https://api.github.com/repos/ViDA-NYU/genotet/releases{/id}","deployments_url":"https://api.github.com/repos/ViDA-NYU/genotet/deployments","created_at":"2014-10-03T15:55:16Z","updated_at":"2016-02-23T03:11:39Z","pushed_at":"2016-03-29T14:28:44Z","git_url":"git://github.com/ViDA-NYU/genotet.git","ssh_url":"git@github.com:ViDA-NYU/genotet.git","clone_url":"https://github.com/ViDA-NYU/genotet.git","svn_url":"https://github.com/ViDA-NYU/genotet","homepage":null,"size":2044,"stargazers_count":5,"watchers_count":5,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":29,"forks":5,"open_issues":29,"watchers":5,"default_branch":"refactor"}},"_links":{"self":{"href":"https://api.github.com/repos/ViDA-NYU/genotet/pulls/158"},"html":{"href":"https://github.com/ViDA-NYU/genotet/pull/158"},"issue":{"href":"https://api.github.com/repos/ViDA-NYU/genotet/issues/158"},"comments":{"href":"https://api.github.com/repos/ViDA-NYU/genotet/issues/158/comments"},"review_comments":{"href":"https://api.github.com/repos/ViDA-NYU/genotet/pulls/158/comments"},"review_comment":{"href":"https://api.github.com/repos/ViDA-NYU/genotet/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ViDA-NYU/genotet/pulls/158/commits"},"statuses":{"href":"https://api.github.com/repos/ViDA-NYU/genotet/statuses/9bf18c42de0b0a3d3a85570c721d72c18adb44ca"}}}}