I am developing a java system [JEE5,JPA,EJB3,JSF,Richfaces,Mysql running on Jboss Seam] and I haven't found a good algorithm to do this I would like to know how do you do something like this:

I want to send videos [7 daily for example] to users registered in the system, so i can send videos sequentially [first day 1-7 second day 8-15 for example] but if I have 700 videos only after 99 days the video number 700 will be seen,if I send them randomly then the video number 50 could be seen 100 times while video number 370 could be seen only 20 times, but the problem is that the database of videos is going to grow for example at the beginning the users could be 800 and 200 videos but the ciphers are going to change fo r example 22000 users and 13000 videos so the performance of the database is critic (the searches and comparisons) any ideas would be very helpful.

thanks for your help and your time

10-17-2009, 07:41 PM

mrmatt1111

You could choose the video randomly and track what video was sent to which user by inserting a row into a tracking table, so as to not send them a video twice.

Since it's random, the number of times a video is watched is more or less evenly distributed. Or, from the tracking table, you could choose the next videos by picking a video with the least views... but i think that would be overkill.

Also it doesn't matter if the number of users or videos grows, you just query the number of videos and then use that to get a random number range.

As far as performance, if you index the tracking table, it should be fast and it won't take up much resources.

10-18-2009, 12:41 AM

thejavaman

thank you very much. I'll build something like that and I'll do tests using your idea.