#518 ✓resolved
Jeremy Nicoll

Test case for children finders

Reported by Jeremy Nicoll | August 6th, 2008 @ 09:57 AM

Just came across something that you might want to look at. In the following code, it returns the same video over and over again, which is not expected behavior. What is expected is for the first video in each category to be returned.

Category.all(:show_on_homepage => true, :order => [:section.asc, :display_order.asc] ).each do |cat|

@sections[cat.section] << cat.videos.first(:air_date.lte => Date.today, :order => [:air_date.desc])

end

The following queries are run:

~ SELECT `id`, `name`, `featuring`, `featuring_url`, `frequency`, `spotexchange_channel`, `show_on_homepage`, `section`, `display_order`, `show_bumper`, `eloop_export`, `eloop_featuring`, `meta_title`, `meta_description`, `meta_keywords` FROM `categories` WHERE `show_on_homepage` = TRUE ORDER BY `section`, `display_order`

~ SELECT `id`, `air_date`, `created_at`, `category_id`, `name`, `featuring`, `summary`, `description`, `featuring_url`, `video_uploaded` FROM `videos` WHERE `air_date` <= '2008-08-06' AND `category_id` IN ('000015', '000001') ORDER BY `air_date` DESC LIMIT 1

~ SELECT `id`, `air_date`, `created_at`, `category_id`, `name`, `featuring`, `summary`, `description`, `featuring_url`, `video_uploaded` FROM `videos` WHERE `air_date` <= '2008-08-06' AND `category_id` IN ('000015', '000001') ORDER BY `air_date` DESC LIMIT 1

As you can see, the same query is run twice. This is in 0.9.4.

Comments and changes to this ticket

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 »

People watching this ticket

Attachments

Pages