{"action":"created","comment":{"url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/pulls/comments/37713781","id":37713781,"diff_hunk":"@@ -585,6 +585,60 @@ module.exports = function (log, error) {\n       )\n   }\n \n+  MySql.prototype.multipleQueries = function (poolName, queries, finalQuery) {\n+    var err\n+    return this.getConnection(poolName)\n+      .then(\n+        function (connection) {\n+          var results = []\n+\n+          return runQuery(0)\n+            .then(\n+              function (results) {\n+                return results\n+              },\n+              function (e) {\n+                err = e\n+              }\n+            )\n+            .finally(\n+              function () {\n+                if (finalQuery) {\n+                  return query(connection, finalQuery.sql, finalQuery.params)\n+                    .finally(finish)\n+                }\n+\n+                finish()\n+\n+                function finish () {\n+                  connection.release()\n+                  if (err) {\n+                    throw err","path":"lib/db/mysql.js","position":32,"original_position":32,"commit_id":"9926f8059cdd9f1b85ffbb6047a058b5c70d4e4f","original_commit_id":"9926f8059cdd9f1b85ffbb6047a058b5c70d4e4f","user":{"login":"rfk","id":34695,"avatar_url":"https://avatars.githubusercontent.com/u/34695?v=3","gravatar_id":"","url":"https://api.github.com/users/rfk","html_url":"https://github.com/rfk","followers_url":"https://api.github.com/users/rfk/followers","following_url":"https://api.github.com/users/rfk/following{/other_user}","gists_url":"https://api.github.com/users/rfk/gists{/gist_id}","starred_url":"https://api.github.com/users/rfk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rfk/subscriptions","organizations_url":"https://api.github.com/users/rfk/orgs","repos_url":"https://api.github.com/users/rfk/repos","events_url":"https://api.github.com/users/rfk/events{/privacy}","received_events_url":"https://api.github.com/users/rfk/received_events","type":"User","site_admin":false},"body":"I *think* this is unnecessary but could easily be wrong.  `finally` is not allowed to change the return value of the promise, so if there was an error then `finally` will be called, its return value ignored, and the error transparently re-raised.  This might also simplify the logic above if you don't have to capture the error into `err` for later throwing.","created_at":"2015-08-24T01:24:07Z","updated_at":"2015-08-24T01:24:07Z","html_url":"https://github.com/mozilla/fxa-auth-db-mysql/pull/80#discussion_r37713781","pull_request_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/pulls/80","_links":{"self":{"href":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/pulls/comments/37713781"},"html":{"href":"https://github.com/mozilla/fxa-auth-db-mysql/pull/80#discussion_r37713781"},"pull_request":{"href":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/pulls/80"}}},"pull_request":{"url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/pulls/80","id":42965626,"html_url":"https://github.com/mozilla/fxa-auth-db-mysql/pull/80","diff_url":"https://github.com/mozilla/fxa-auth-db-mysql/pull/80.diff","patch_url":"https://github.com/mozilla/fxa-auth-db-mysql/pull/80.patch","issue_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/issues/80","number":80,"state":"open","locked":false,"title":"feat(db): add script for reporting metrics","user":{"login":"philbooth","id":64367,"avatar_url":"https://avatars.githubusercontent.com/u/64367?v=3","gravatar_id":"","url":"https://api.github.com/users/philbooth","html_url":"https://github.com/philbooth","followers_url":"https://api.github.com/users/philbooth/followers","following_url":"https://api.github.com/users/philbooth/following{/other_user}","gists_url":"https://api.github.com/users/philbooth/gists{/gist_id}","starred_url":"https://api.github.com/users/philbooth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/philbooth/subscriptions","organizations_url":"https://api.github.com/users/philbooth/orgs","repos_url":"https://api.github.com/users/philbooth/repos","events_url":"https://api.github.com/users/philbooth/events{/privacy}","received_events_url":"https://api.github.com/users/philbooth/received_events","type":"User","site_admin":false},"body":"Fixes #72.\r\n\r\nThis is essentially a like-for-like replacement for [`puppet-config/.../gather_basic_metrics.py`](https://github.com/mozilla-services/puppet-config/blob/master/fxa/modules/fxa_admin/files/gather_basic_metrics.py), except written for node.js and covered by tests.\r\n\r\nAlthough it is part of this repo, the plan is for it to run from the same context as the Python script, hence the file paths and the [non-JSON config format](https://github.com/mozilla-services/puppet-config/blob/master/fxa/modules/fxa_admin/templates/gather_basic_metrics.conf.erb). By having it in this repo, we get the benefit of the tests running automatically against future schema changes.\r\n\r\nI plan to commit some more tests tomorrow, but wanted to get feedback on it sooner than that because we're so close to the end of this train.\r\n\r\nThere are a few things in particular that I was unsure about:\r\n\r\n* Am I passing the correct options to `mysql.connect`?\r\n* Is it right or wrong to call `log.error` from this context?\r\n* Is the `readUncommitted` parameter too hackish?\r\n\r\n@jrgm and @rfk, feedback wanted! :smile: ","created_at":"2015-08-20T19:03:04Z","updated_at":"2015-08-24T01:24:07Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fe135bbc32933da3051e28a5f56822d642116c94","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/pulls/80/commits","review_comments_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/pulls/80/comments","review_comment_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/issues/80/comments","statuses_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/statuses/9926f8059cdd9f1b85ffbb6047a058b5c70d4e4f","head":{"label":"mozilla:phil/issue-72","ref":"phil/issue-72","sha":"9926f8059cdd9f1b85ffbb6047a058b5c70d4e4f","user":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"repo":{"id":23937466,"name":"fxa-auth-db-mysql","full_name":"mozilla/fxa-auth-db-mysql","owner":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mozilla/fxa-auth-db-mysql","description":"MySql backend for the fxa-auth-db-server","fork":false,"url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql","forks_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/forks","keys_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/teams","hooks_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/hooks","issue_events_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/events","assignees_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/tags","blobs_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/languages","stargazers_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/stargazers","contributors_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/contributors","subscribers_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/subscribers","subscription_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/subscription","commits_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/issues/comments{/number}","contents_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/merges","archive_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/downloads","issues_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/labels{/name}","releases_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/releases{/id}","created_at":"2014-09-11T22:06:52Z","updated_at":"2015-06-25T04:52:09Z","pushed_at":"2015-08-22T11:28:33Z","git_url":"git://github.com/mozilla/fxa-auth-db-mysql.git","ssh_url":"git@github.com:mozilla/fxa-auth-db-mysql.git","clone_url":"https://github.com/mozilla/fxa-auth-db-mysql.git","svn_url":"https://github.com/mozilla/fxa-auth-db-mysql","homepage":"","size":1034,"stargazers_count":3,"watchers_count":3,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":10,"mirror_url":null,"open_issues_count":3,"forks":10,"open_issues":3,"watchers":3,"default_branch":"master"}},"base":{"label":"mozilla:master","ref":"master","sha":"354fc512d181b002b7aa62740889eaf60511a2d7","user":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"repo":{"id":23937466,"name":"fxa-auth-db-mysql","full_name":"mozilla/fxa-auth-db-mysql","owner":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mozilla/fxa-auth-db-mysql","description":"MySql backend for the fxa-auth-db-server","fork":false,"url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql","forks_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/forks","keys_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/teams","hooks_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/hooks","issue_events_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/events","assignees_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/tags","blobs_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/languages","stargazers_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/stargazers","contributors_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/contributors","subscribers_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/subscribers","subscription_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/subscription","commits_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/issues/comments{/number}","contents_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/merges","archive_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/downloads","issues_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/labels{/name}","releases_url":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/releases{/id}","created_at":"2014-09-11T22:06:52Z","updated_at":"2015-06-25T04:52:09Z","pushed_at":"2015-08-22T11:28:33Z","git_url":"git://github.com/mozilla/fxa-auth-db-mysql.git","ssh_url":"git@github.com:mozilla/fxa-auth-db-mysql.git","clone_url":"https://github.com/mozilla/fxa-auth-db-mysql.git","svn_url":"https://github.com/mozilla/fxa-auth-db-mysql","homepage":"","size":1034,"stargazers_count":3,"watchers_count":3,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":10,"mirror_url":null,"open_issues_count":3,"forks":10,"open_issues":3,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/pulls/80"},"html":{"href":"https://github.com/mozilla/fxa-auth-db-mysql/pull/80"},"issue":{"href":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/issues/80"},"comments":{"href":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/issues/80/comments"},"review_comments":{"href":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/pulls/80/comments"},"review_comment":{"href":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/pulls/80/commits"},"statuses":{"href":"https://api.github.com/repos/mozilla/fxa-auth-db-mysql/statuses/9926f8059cdd9f1b85ffbb6047a058b5c70d4e4f"}}}}