{"action":"created","issue":{"url":"https://api.github.com/repos/rethinkdb/rethinkdb/issues/6547","repository_url":"https://api.github.com/repos/rethinkdb/rethinkdb","labels_url":"https://api.github.com/repos/rethinkdb/rethinkdb/issues/6547/labels{/name}","comments_url":"https://api.github.com/repos/rethinkdb/rethinkdb/issues/6547/comments","events_url":"https://api.github.com/repos/rethinkdb/rethinkdb/issues/6547/events","html_url":"https://github.com/rethinkdb/rethinkdb/issues/6547","id":274379414,"number":6547,"title":".randomify() - make the table's documents random (read before assuming)","user":{"login":"PassTheMayo","id":16949253,"avatar_url":"https://avatars3.githubusercontent.com/u/16949253?v=4","gravatar_id":"","url":"https://api.github.com/users/PassTheMayo","html_url":"https://github.com/PassTheMayo","followers_url":"https://api.github.com/users/PassTheMayo/followers","following_url":"https://api.github.com/users/PassTheMayo/following{/other_user}","gists_url":"https://api.github.com/users/PassTheMayo/gists{/gist_id}","starred_url":"https://api.github.com/users/PassTheMayo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PassTheMayo/subscriptions","organizations_url":"https://api.github.com/users/PassTheMayo/orgs","repos_url":"https://api.github.com/users/PassTheMayo/repos","events_url":"https://api.github.com/users/PassTheMayo/events{/privacy}","received_events_url":"https://api.github.com/users/PassTheMayo/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-11-16T03:05:16Z","updated_at":"2017-11-16T14:55:59Z","closed_at":null,"author_association":"NONE","body":"I can probably know what you are gonna say from the title, but this has nothing to do with `.sample()` or `r.random()`. I recently came across a problem that I had no solution for. I own a large list of Discord bots, but I have no way to random-ify the results (on an hourly basis). For example, the documents in the table are random, but an hour later, they are in another random order. I think that this could be accomplished with a new chaining function, called `.randomify()`. This will make the order of the documents in the table random. For example, if I wanted to make the order of the documents in table `bots` random, I could use the following method: `r.table(\"bots\").randomify().run(r.conn, ...)`. If I wanted to get the results of the new order, I could use this:\r\n```js\r\nr.table(\"bots\").randomify().run(r.conn, function (error, results) {\r\n    if (error) ...\r\n    // do something with the new order of 'results'\r\n});\r\n```\r\nThis would be **very** helpful to me, and possibly other people too. Thanks!"},"comment":{"url":"https://api.github.com/repos/rethinkdb/rethinkdb/issues/comments/344947154","html_url":"https://github.com/rethinkdb/rethinkdb/issues/6547#issuecomment-344947154","issue_url":"https://api.github.com/repos/rethinkdb/rethinkdb/issues/6547","id":344947154,"user":{"login":"srh","id":258437,"avatar_url":"https://avatars1.githubusercontent.com/u/258437?v=4","gravatar_id":"","url":"https://api.github.com/users/srh","html_url":"https://github.com/srh","followers_url":"https://api.github.com/users/srh/followers","following_url":"https://api.github.com/users/srh/following{/other_user}","gists_url":"https://api.github.com/users/srh/gists{/gist_id}","starred_url":"https://api.github.com/users/srh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/srh/subscriptions","organizations_url":"https://api.github.com/users/srh/orgs","repos_url":"https://api.github.com/users/srh/repos","events_url":"https://api.github.com/users/srh/events{/privacy}","received_events_url":"https://api.github.com/users/srh/received_events","type":"User","site_admin":false},"created_at":"2017-11-16T14:55:59Z","updated_at":"2017-11-16T14:55:59Z","author_association":"CONTRIBUTOR","body":"That's right -- the recommended way to do a random shuffle is that.\r\n\r\nIf you want the order to change once an hour, you could use `r.uuid` on a combination of the document ID and current hour to deterministically produce a random ordering that changes every hour (while running the query more than once)."}}
{"actor":{"display_login":"srh"}}