Oops, don't return body_id=0 items for "-fits:blue-acara"
Right, fitting isn't just body_id = this one, it's also body_id=0! Anyway, doing this query on its own is still deathly slow, I wonder if the idea I had about left joins (back when I was still working in a Rails version that didn't support it lol) could help! Might poke at that a smidge.
This commit is contained in:
parent
671a79d158
commit
183cb40e74
1 changed files with 5 additions and 1 deletions
|
@ -103,7 +103,11 @@ class Item < ApplicationRecord
|
||||||
# bother looking into this, but one thing I notice is items with no assets
|
# bother looking into this, but one thing I notice is items with no assets
|
||||||
# somehow would not match either scope in this impl (but LEFT JOIN would!)
|
# somehow would not match either scope in this impl (but LEFT JOIN would!)
|
||||||
joins(:swf_assets).group(i[:id]).
|
joins(:swf_assets).group(i[:id]).
|
||||||
having('FIND_IN_SET(?, GROUP_CONCAT(body_id)) = 0', body_id).
|
having(
|
||||||
|
"FIND_IN_SET(?, GROUP_CONCAT(body_id)) = 0 AND " +
|
||||||
|
"FIND_IN_SET(0, GROUP_CONCAT(body_id)) = 0",
|
||||||
|
body_id
|
||||||
|
).
|
||||||
distinct
|
distinct
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue