Skip to content

Instantly share code, notes, and snippets.

@gfmurphy
Last active August 29, 2015 14:15
Show Gist options
  • Save gfmurphy/d408da3f91b17c266a0e to your computer and use it in GitHub Desktop.
Save gfmurphy/d408da3f91b17c266a0e to your computer and use it in GitHub Desktop.
Noindex deal criteria - i.e. instruct search engines to ignore deals (and remove from index) and *not* publish in xml sitemap.
# Deal types currently included in xml sitemap
# * "LocalDeal", "EscapesDeal", "AtHomeDeal", "FamiliesDeal"
# * live event deals are included
# URLs are generated with LS::Routing
# * Need to support a mobile version of the url for alternate content and mobile sitemap in near future.
def search_engine_ignore?(deal)
deal.exclusive? || deal.boomerang? || !deal.active?
end
# this logic expands to
def search_engine_ignore?(deal)
# deal.exlusive? - bitfield in deals db. name defined in LS::Deals
# deal.boomerang? - DealEvergreenPreferece is associated to Deal as has_one in deals db.
# deal.active? - current time is within the overall deal runtime AND all options are available for purchase and !sold_out
deal.exclusive? || deal.deal_evergreen_preference.present?
|| !(((!!(deal.offer_starts_at && deal.offer_ends_at)) && deal.offer_starts_at <= Time.current && Time.current < deal.offer_ends_at) && !(deal.options.select(&:available_for_purchase).all?(&:sold_out?)))
end
@timbogit
Copy link

You might want to check for TZs?!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment