forked from OpenNeo/impress
oops, deal with missing item fields better
This commit is contained in:
parent
0b32e8ba59
commit
206811a2fb
3 changed files with 9 additions and 7 deletions
|
@ -47,7 +47,7 @@ class OutfitsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
unless localized_fragment_exist?('outfits#new newest_items')
|
unless localized_fragment_exist?('outfits#new newest_items')
|
||||||
@newest_items = Item.newest.select([:id, :name, :thumbnail_url]).
|
@newest_items = Item.newest.select([:id, :thumbnail_url]).
|
||||||
includes(:translations).limit(9)
|
includes(:translations).limit(9)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,11 @@ class ClosetHanger < ActiveRecord::Base
|
||||||
|
|
||||||
validate :list_belongs_to_user
|
validate :list_belongs_to_user
|
||||||
|
|
||||||
scope :alphabetical_by_item_name, joins(:item).order(Item.arel_table[:name])
|
scope :alphabetical_by_item_name, lambda {
|
||||||
|
joins(:item => :translations).
|
||||||
|
where(Item::Translation.arel_table[:locale].eq(I18n.locale)).
|
||||||
|
order(Item.arel_table[:name])
|
||||||
|
}
|
||||||
scope :newest, order(arel_table[:created_at].desc)
|
scope :newest, order(arel_table[:created_at].desc)
|
||||||
scope :owned_before_wanted, order(arel_table[:owned].desc)
|
scope :owned_before_wanted, order(arel_table[:owned].desc)
|
||||||
scope :unlisted, where(:list_id => nil)
|
scope :unlisted, where(:list_id => nil)
|
||||||
|
|
|
@ -23,7 +23,6 @@ class Item < ActiveRecord::Base
|
||||||
cattr_reader :per_page
|
cattr_reader :per_page
|
||||||
@@per_page = 30
|
@@per_page = 30
|
||||||
|
|
||||||
scope :alphabetize, order(arel_table[:name])
|
|
||||||
scope :alphabetize_by_translations, lambda {
|
scope :alphabetize_by_translations, lambda {
|
||||||
it = Item::Translation.arel_table
|
it = Item::Translation.arel_table
|
||||||
order(it[:name])
|
order(it[:name])
|
||||||
|
@ -38,8 +37,7 @@ class Item < ActiveRecord::Base
|
||||||
scope :sold_in_mall, where(:sold_in_mall => true)
|
scope :sold_in_mall, where(:sold_in_mall => true)
|
||||||
scope :not_sold_in_mall, where(:sold_in_mall => false)
|
scope :not_sold_in_mall, where(:sold_in_mall => false)
|
||||||
|
|
||||||
scope :sitemap, select([arel_table[:id], arel_table[:name]]).
|
scope :sitemap, order([:id]).limit(49999)
|
||||||
order(arel_table[:id]).limit(49999)
|
|
||||||
|
|
||||||
scope :with_closet_hangers, joins(:closet_hangers)
|
scope :with_closet_hangers, joins(:closet_hangers)
|
||||||
|
|
||||||
|
@ -433,7 +431,7 @@ class Item < ActiveRecord::Base
|
||||||
all_item_ids = items.keys
|
all_item_ids = items.keys
|
||||||
# Find which of these already exist but aren't marked as sold_in_mall so
|
# Find which of these already exist but aren't marked as sold_in_mall so
|
||||||
# we can update them as being sold
|
# we can update them as being sold
|
||||||
Item.not_sold_in_mall.where(:id => items.keys).select([:id, :name]).each do |item|
|
Item.not_sold_in_mall.where(:id => items.keys).select([:id]).each do |item|
|
||||||
items.delete(item.id)
|
items.delete(item.id)
|
||||||
item.sold_in_mall = true
|
item.sold_in_mall = true
|
||||||
item.save
|
item.save
|
||||||
|
@ -460,7 +458,7 @@ class Item < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def spider_mall_assets!(limit)
|
def spider_mall_assets!(limit)
|
||||||
items = self.select([arel_table[:id], arel_table[:name]]).sold_in_mall.spidered_longest_ago.limit(limit).all
|
items = self.select([arel_table[:id]]).sold_in_mall.spidered_longest_ago.limit(limit).all
|
||||||
puts "- #{items.size} items need asset spidering"
|
puts "- #{items.size} items need asset spidering"
|
||||||
AssetStrategy.build_strategies
|
AssetStrategy.build_strategies
|
||||||
items.each do |item|
|
items.each do |item|
|
||||||
|
|
Loading…
Reference in a new issue