init push - laying out the project
This commit is contained in:
25
portal/app/helpers/application_helper.rb
Normal file
25
portal/app/helpers/application_helper.rb
Normal file
@ -0,0 +1,25 @@
|
||||
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
|
Reference in New Issue
Block a user