From 0074e54417fb966fd77e982a103a941d437d00fb Mon Sep 17 00:00:00 2001 From: Matchu Date: Wed, 20 Feb 2013 00:58:41 -0600 Subject: [PATCH] tweak to avoid certain single-species items: count distinct body IDs in other assets --- app/models/pet_type.rb | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/app/models/pet_type.rb b/app/models/pet_type.rb index 9df9de77..0b501dbb 100644 --- a/app/models/pet_type.rb +++ b/app/models/pet_type.rb @@ -96,11 +96,7 @@ class PetType < ActiveRecord::Base psa = ParentSwfAssetRelationship.arel_table sa = SwfAsset.arel_table - # Close, but no cigar: if we just check for the presence of *one* other - # body-specific asset, it'll also include single-species items for other - # species. We should check for more than one... but I'm not sure how to - # do that in Arel... - Item.where('(' + ParentSwfAssetRelationship.select('count(*)').joins(:swf_asset). + Item.where('(' + ParentSwfAssetRelationship.select('count(DISTINCT body_id)').joins(:swf_asset). where( psa[:parent_id].eq(i[:id]).and( psa[:parent_type].eq('Item').and(