mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-01-03 06:57:50 -05:00
This change migrates the crop description from the `openfarm_data` JSONB field to a new, dedicated `description` text column in the `crops` table. A data migration is included to move the existing description data to the new column. The `OpenFarmData` concern is updated to remove the now-redundant `description` method.
45 lines
747 B
Ruby
45 lines
747 B
Ruby
# frozen_string_literal: true
|
|
|
|
module OpenFarmData
|
|
extend ActiveSupport::Concern
|
|
|
|
included do
|
|
def of_photo
|
|
fetch_attr('main_image_path')
|
|
end
|
|
|
|
def svg_icon
|
|
icon = fetch_attr('svg_icon')
|
|
return icon if icon.present?
|
|
|
|
parent.svg_icon if parent.present?
|
|
end
|
|
|
|
def tags_array
|
|
fetch_attr('tags_array')
|
|
end
|
|
|
|
def common_names
|
|
fetch_attr('common_names')
|
|
end
|
|
|
|
def binomial_name
|
|
fetch_attr('binomial_name')
|
|
end
|
|
|
|
def main_image_path
|
|
fetch_attr('main_image_path')
|
|
end
|
|
|
|
def processing_pictures
|
|
fetch_attr('processing_pictures')
|
|
end
|
|
end
|
|
|
|
def fetch_attr(key)
|
|
return if openfarm_data.blank?
|
|
|
|
openfarm_data.dig('attributes', key)
|
|
end
|
|
end
|