I would like to retrieve a random collection of items paginated with a particular weight on the created_at.
I successfully retrieved a random collection paginated with postgres option setseed.
The thing is, how do I combine some sort of weighing on created_at in my collection (which will give a better chance for the weighed items to be in the random sample) and this setseed option with postgres.
I'm thinking of something like retrieving the items, add them the weight I want and then do my random request but I think it will not be good performance-wise.
I'm in a kind of a dead end there and I don't know how to approach this issue.
Here is what I did for now :
Simply using setseed option to have a different batch of random items on each of my pages :
Item.connection.execute "select setseed(0.5)"
Item.where(...).order('random()').page(params[:page]).per_page(15)