{"action":"created","issue":{"url":"https://api.github.com/repos/TylerBrock/mongo-hacker/issues/150","repository_url":"https://api.github.com/repos/TylerBrock/mongo-hacker","labels_url":"https://api.github.com/repos/TylerBrock/mongo-hacker/issues/150/labels{/name}","comments_url":"https://api.github.com/repos/TylerBrock/mongo-hacker/issues/150/comments","events_url":"https://api.github.com/repos/TylerBrock/mongo-hacker/issues/150/events","html_url":"https://github.com/TylerBrock/mongo-hacker/pull/150","id":130357040,"number":150,"title":"Handle multiple (ie. more than 2) columns","user":{"login":"pvdb","id":17322,"avatar_url":"https://avatars.githubusercontent.com/u/17322?v=3","gravatar_id":"","url":"https://api.github.com/users/pvdb","html_url":"https://github.com/pvdb","followers_url":"https://api.github.com/users/pvdb/followers","following_url":"https://api.github.com/users/pvdb/following{/other_user}","gists_url":"https://api.github.com/users/pvdb/gists{/gist_id}","starred_url":"https://api.github.com/users/pvdb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pvdb/subscriptions","organizations_url":"https://api.github.com/users/pvdb/orgs","repos_url":"https://api.github.com/users/pvdb/repos","events_url":"https://api.github.com/users/pvdb/events{/privacy}","received_events_url":"https://api.github.com/users/pvdb/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-02-01T13:02:53Z","updated_at":"2016-02-10T10:03:52Z","closed_at":"2016-02-09T22:09:20Z","pull_request":{"url":"https://api.github.com/repos/TylerBrock/mongo-hacker/pulls/150","html_url":"https://github.com/TylerBrock/mongo-hacker/pull/150","diff_url":"https://github.com/TylerBrock/mongo-hacker/pull/150.diff","patch_url":"https://github.com/TylerBrock/mongo-hacker/pull/150.patch"},"body":"Hey @TylerBrock,\r\n\r\nIn https://github.com/TylerBrock/mongo-hacker/pull/148#discussion_r51252848 I wrote:\r\n>  [it] requires a pretty significant refactor of the `printPaddedColumns()` function in `hacks/helpers/js`, mainly to support multiple columns _(instead of just two, which it does currently)_\r\n\r\n... here it is, in all its glory, the refactoring of  `printPaddedColumns()` to support multiple _(ie. more than 2)_ colums.\r\n\r\nThe `printPaddedColumns()` function has changed so much that the GitHub diff is probably meaningless, so probably better to just grok the new version.\r\n\r\nThanks to the new implementation, though, I was able to get rid of the now-superfluous `mergePaddedValues()` function, as that function just made up for the lack of proper multi-column support in `printPaddedColumns()`.\r\n\r\nThe main benefits of this new version are (1) how it simplifies printing out multiple padded columns, and (2) how it supports a variable number of columns _(1 upto ∞, in theory at least :smile:)_:\r\n\r\n**before**\r\n\r\n```js\r\nprintPaddedColumns(collectionNames, mergePaddedValues(collectionSizes, collectionStorageSizes));\r\n```\r\n\r\n**after**\r\n\r\n```js\r\nprintPaddedColumns(collectionNames, collectionSizes, collectionStorageSizes);\r\n```\r\n\r\n... which will enable me to merge this into #148 to implement the \"dynamic\" padding you wanted to fix first.\r\n\r\nGoing forward, this function can be used to print and layout even more columns, not just the three that we have at the moment:\r\n\r\n```shell\r\nmacpvandenb(mongod-3.2.1) test> printPaddedColumns([\"first\", \"second\", \"third\"], [\"foo\", 2, 3], [4, \"bar\", 6], [7, 8, \"qux\"], [0, \"blegga\", 0])\r\nfirst  → foo /   4 /   7 /      0\r\nsecond →   2 / bar /   8 / blegga\r\nthird  →   3 /   6 / qux /      0\r\nnull\r\nmacpvandenb(mongod-3.2.1) test> _\r\n```\r\n\r\nBTW: this PR is again a pure refactoring of existing logic, it doesn't change anything functionally, as you can verify by running the `show dbs`, `count collections`, `show collections`, and `count documents` shell commands... they behave exactly as before, and their output is identical. So much win!  :smile:"},"comment":{"url":"https://api.github.com/repos/TylerBrock/mongo-hacker/issues/comments/182287405","html_url":"https://github.com/TylerBrock/mongo-hacker/pull/150#issuecomment-182287405","issue_url":"https://api.github.com/repos/TylerBrock/mongo-hacker/issues/150","id":182287405,"user":{"login":"pvdb","id":17322,"avatar_url":"https://avatars.githubusercontent.com/u/17322?v=3","gravatar_id":"","url":"https://api.github.com/users/pvdb","html_url":"https://github.com/pvdb","followers_url":"https://api.github.com/users/pvdb/followers","following_url":"https://api.github.com/users/pvdb/following{/other_user}","gists_url":"https://api.github.com/users/pvdb/gists{/gist_id}","starred_url":"https://api.github.com/users/pvdb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pvdb/subscriptions","organizations_url":"https://api.github.com/users/pvdb/orgs","repos_url":"https://api.github.com/users/pvdb/repos","events_url":"https://api.github.com/users/pvdb/events{/privacy}","received_events_url":"https://api.github.com/users/pvdb/received_events","type":"User","site_admin":false},"created_at":"2016-02-10T10:03:52Z","updated_at":"2016-02-10T10:03:52Z","body":"> Thank you for doing the work on this...\r\n\r\nNP, it's a good way for me to level up on JS!"}}