#82 ✓resolved
Tien Dung

not_heard_by(user, limit) return listened assets

Reported by Tien Dung | October 9th, 2008 @ 04:55 AM

it FAILs because of “user.listens.size > 10”. When it’s not true. conditions == nil => The function gets a random tracks of all tracks, including ones listened by the user.

def self.not_heard_by(user, limit) conditions = (user && user.listens.size > 10 ) ? [“assets.id NOT IN (?) ”,user.listened_to_ids] : nil Asset.find(:all, :conditions => conditions, :order => ‘RAND’, :limit => limit) end

Comments and changes to this ticket

  • sudara

    sudara October 9th, 2008 @ 05:31 AM

    I think we just need to change user.listens.size > 1

    That says "If user has ever listened to a song before, then get random radio tracks WITHOUT those songs, otherwise, just get random tracks"

  • Tien Dung

    Tien Dung October 9th, 2008 @ 02:44 PM

    I think should change to user.listens.size > 0

    And we can use user.listens.count instead of .size. If I'm not wrong. user.listens.size will query all listens in an array first then calculate the size of the array. user.listens.count will use SQL COUNT to get the number.

  • sudara

    sudara October 10th, 2008 @ 11:15 AM

    That sounds perfect :)

  • sudara

    sudara October 16th, 2008 @ 06:30 AM

    • Assigned user changed from “sudara” to “Tien Dung”
    • State changed from “new” to “resolved”

    I think this is resolved?

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

kick ass musician's home.

Shared Ticket Bins

People watching this ticket

Tags

Pages