Skip to content

Instantly share code, notes, and snippets.

@saveroo
Created December 19, 2016 07:10
Show Gist options
  • Save saveroo/d69b222e084f4dc7e17d7468c4867701 to your computer and use it in GitHub Desktop.
Save saveroo/d69b222e084f4dc7e17d7468c4867701 to your computer and use it in GitHub Desktop.
multiternary
@units = Unit.where(id: @unit_discount.map(&:unit_id) + @search.result.pluck(:unit_id) +
(params[:q].present? ? AvailabilityFact.where(vendor_id: @vendor.id)
.all_unit_inventory_at(Date.new(params[:q]['valid_date_gteq(1i)'].to_i, params[:q]['valid_date_gteq(2i)'].to_i, params[:q]['valid_date_gteq(3i)'].to_i),
Date.new(params[:q]['valid_date_lteq(1i)'].to_i, params[:q]['valid_date_lteq(2i)'].to_i, params[:q]['valid_date_lteq(3i)'].to_i)).pluck(:unit_id) : []))
.where { id << hidden_unit }.includes(:stock, variant: :product).joins(variant: :product).order('products.name ASC').page(params[:page]).per_page(50)
if params[:q]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment