26 lines
707 B
Ruby
26 lines
707 B
Ruby
module ApplicationHelper
|
|
def render_activities(_activities)
|
|
'Activities'
|
|
end
|
|
|
|
def filter_by_date_range(records, field_string)
|
|
return records if field_string.blank?
|
|
|
|
field = params[field_string.to_sym]
|
|
|
|
return records unless field
|
|
|
|
ea_symbolize = JSON.parse(field).symbolize_keys
|
|
|
|
parsed_date_from = nil
|
|
parsed_date_to = nil
|
|
|
|
parsed_date_from = DateTime.parse(ea_symbolize[:from]) unless ea_symbolize[:from].nil?
|
|
parsed_date_to = DateTime.parse(ea_symbolize[:to]) unless ea_symbolize[:to].nil?
|
|
|
|
records = records.where("#{field_string} >= ? AND #{field_string} <= ?", parsed_date_from, parsed_date_to + 1.day) unless parsed_date_from.nil?
|
|
|
|
records
|
|
end
|
|
end
|