Skip to content

Instantly share code, notes, and snippets.

@vddgil
Created June 21, 2021 09:34
Show Gist options
  • Save vddgil/41aa5ff3d4507baf5b0eb919e18a7b16 to your computer and use it in GitHub Desktop.
Save vddgil/41aa5ff3d4507baf5b0eb919e18a7b16 to your computer and use it in GitHub Desktop.
algoliasearch per_environment: true, enqueue: true, index_name: "emails" do
attributes :id, :email, :co_worker_id, :primary
attribute(:account_id) { co_worker.account_id }
attribute(:have_department) { department_id.present? }
attribute :attributes do
co_worker_attribute_values.map do |v|
{ slug: v.co_worker_attribute.slug, value: v.value }
end
end
attribute :co_worker do
{
id: co_worker.id,
first_name: co_worker.first_name,
last_name: co_worker.last_name,
job_position: co_worker.job_position,
profile_picture_url: co_worker.cropped_profile_picture.attached? ? Rails.application.routes.url_helpers.rails_representation_url(co_worker.cropped_profile_picture.variant(resize_to_limit: [120, 120]), host: CONFIG[:host], protocol: CONFIG[:protocol]) : nil
}
end
attribute :department do
{
id: department.try(:id),
display_name: department.try(:display_name)
}
end
searchableAttributes ["email", "attributes.value"]
attributesForFaceting ["account_id", "department.id", "primary", "co_worker_id"]
attributeForDistinct "co_worker_id"
unretrievableAttributes ["account_id"]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment