add template submissions filters

This commit is contained in:
Alex Turchyn authored and Pete Matsyburka committed 2024-11-22 22:23:20 +02:00
1 parent c2eb94b571
commit b86aac86d1
13 files changed
+484 -51

No files matched your search

+17
View File
@@ -115,4 +115,21 @@ class ApplicationController < ActionController::Base
redirect_to request.url.gsub('.co/', '.com/'), allow_other_host: true, status: :moved_permanently
end
def date_range(key)
p = params.permit(key => %i[from to]).fetch(key, {})
timezone = ActiveSupport::TimeZone[current_account.timezone] || Time.zone
start_date = timezone.parse(p[:from]) if p[:from].present?
end_date = timezone.parse(p[:to]) if p[:to].present?
if start_date.present? && end_date.present? && start_date < end_date
start_date..end_date
elsif start_date.present? && end_date.present? && start_date == end_date
start_date.beginning_of_day..end_date.end_of_day
elsif start_date.present?
start_date..
elsif end_date.present?
..end_date
end
end
end