notebook/script/top_values.rb
2020-04-06 16:35:31 -05:00

8 lines
395 B
Ruby

page_type = Vehicle
field = 'Type of vehicle'
cats = AttributeCategory.where(entity_type: page_type.name.downcase, label: 'Overview').pluck(:id)
fs = AttributeField.where(attribute_category_id: cats, label: field).pluck(:id)
Attribute.where(attribute_field_id: fs).where.not(value: [nil, ""]).group(:value).order('count_id DESC').limit(100).count(:id).keys.map { |k| k.downcase.strip }.sort