Created
February 11, 2015 19:53
-
-
Save ArunGupta25/ccc8d23f357149c0e59e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Listing.reindex! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Listing < ActiveRecord::Base | |
include AlgoliaSearch | |
algoliasearch per_environment: true, if: :saleable? do | |
attribute :title, :designer, :price, :description, :size, :category, :price_drops, :dropped, :price_updated_at, :created_at, :cover_photo, :images_processed, :bumped_at, :location, :strata, :retina_cover_photo, :retina_cover_height, :retina_cover_width, :followerno | |
attributesToIndex ['unordered(designer)', 'unordered(title)', 'unordered(description)', 'category', 'size', 'price'] | |
customRanking ['desc(price_updated_at)'] | |
ranking ['custom', 'desc(followerno)', 'typo', 'geo', 'words', 'proximity', 'attribute', 'exact'] | |
synonyms [ | |
["footwear", "shoes"], | |
["bottoms", "pants"], | |
["outerwear", "jacket"] | |
] | |
add_slave 'Listing_by_date_added', per_environment: true do | |
customRanking ['desc(created_at)'] | |
ranking ['custom', 'typo', 'geo', 'words', 'proximity', 'attribute', 'exact'] | |
end | |
add_slave 'Listing_by_followers', per_environment: true do | |
customRanking ['desc(created_at)'] | |
ranking ['desc(followerno)', 'typo', 'geo', 'words', 'proximity', 'attribute', 'exact', 'custom'] | |
end | |
add_slave 'Listing_by_high_price', per_environment: true do | |
ranking ['desc(price)', 'typo', 'geo', 'words', 'proximity', 'attribute', 'exact', 'desc(followerno)'] | |
end | |
add_slave 'Listing_by_low_price', per_environment: true do | |
ranking ['asc(price)', 'typo', 'geo', 'words', 'proximity', 'attribute', 'exact', 'desc(followerno)'] | |
end | |
end | |
def saleable? | |
self.sold == nil && self.images_processed == true && ['grailed',nil].include?(self.strata) && [false,nil].include?(self.deleted) | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- !ruby/ActiveRecord:Listing | |
attributes: | |
id: 61431 | |
user_id: 2 | |
title: hello there | |
created_at: 2015-02-11 03:06:09.172737000 Z | |
updated_at: 2015-02-11 03:06:13.324638000 Z | |
designer: A.P.C. | |
price: 22.0 | |
description: hello | |
size: '34' | |
category: bottoms | |
sold: | |
paypal_id: [email protected] | |
sold_price: | |
sold_at: | |
color: | |
buyer_id: | |
price_drops: [] | |
dropped: | |
price_updated_at: 2015-02-11 03:06:09.172737000 Z | |
cover_photo: http://assets1.grailed.com/uploads/photo/image/289972/display_upload_2F1423623967192-2efw2ikevu7919k9-43fb48f4f7a6ef13bd117a6a2cfef6d4_2F.jpeg | |
images_processed: true | |
buynow: false | |
makeoffer: true | |
shipto: '' | |
shipcost: | |
bumped_at: 2015-02-11 03:06:09.172192000 Z | |
location: United Kingdom | |
strata: grailed | |
deleted: | |
deleted_at: | |
followerno: 0 | |
repost: | |
repost_id: | |
refresh: | |
retina_cover_photo: http://assets3.grailed.com/uploads/photo/image/289972/showpage_upload_2F1423623967192-2efw2ikevu7919k9-43fb48f4f7a6ef13bd117a6a2cfef6d4_2F.jpeg | |
retina_cover_width: 306 | |
retina_cover_height: 306 | |
currency: USD |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey @ArunGupta25, weird :/ Can you confirm the algoliasearch-rails version you're currently using?