-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wheight by created_at #30
Comments
Here is some idea: to be put somehow here
|
I haven't had much time to devote to randumb as of late. If you implement this feel free to make a pull request and I can consider merging it in :) I'm curious what your use case is for needing this. You may be able to achieve what you need by using a where clause to omit old records: User.where(['created_at > ?', 1.year.ago]).order_by_rand.limit(3).to_a |
thank, I am a little bit idiot I think! ;-) I don't feel I can implement it, it seams I would need to check if it is numeric or not and if not do something but I don't understand so much how randumb work and where I should do that right now! It is slightly different though,
since the second should theorically probably return something older than 1 year ago no? thank you |
Yes you are correct, I'm just trying to understand your use case (ie why you need things weighted by created date). For me when I have needed to do things like that I have just opted to not show things older than a certain date and randomize the things after that date. This performs well because you can cut out a large number of records to perform the rand() on. If you further complicate the function is has to perform on every record, it will be even slower on large result sets. |
yes this is true, I may as well do like you, but it is still only better than nothing! I have no real use case right now since I will be creating a numeric score value shortly, better just do as you said. but even:
If we think about distribution, there will be a flat distribution in time from the second and a poisson distribution or something similar from the first which again seams to me way better. what do you think? |
Feel free to give it a go if you want to build it and make a pull request, but as mentioned earlier, I unfortunately do not have time at the moment to implement any real features like this myself. |
Hi,
since created_at is not a directly considered numeric but still very numeric in nature, it would be great and probably not so hard to implement wheight random that work on date time.
could someone help me on that?
thank you very much
The text was updated successfully, but these errors were encountered: