mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-01 11:37:58 +00:00
* feat: include timezone offset in summary calculation * fix: exlcude end in date range * test: explicit end of day * fix: test for report builder * fix: reports.spec.js --------- Co-authored-by: Tejaswini Chile <tejaswini@chatwoot.com>
20 lines
602 B
Ruby
20 lines
602 B
Ruby
##############################################
|
|
# Helpers to implement date range filtering to APIs
|
|
# Include in your controller or service class where params is available
|
|
##############################################
|
|
|
|
module DateRangeHelper
|
|
def range
|
|
return if params[:since].blank? || params[:until].blank?
|
|
|
|
parse_date_time(params[:since])...parse_date_time(params[:until])
|
|
end
|
|
|
|
def parse_date_time(datetime)
|
|
return datetime if datetime.is_a?(DateTime)
|
|
return datetime.to_datetime if datetime.is_a?(Time) || datetime.is_a?(Date)
|
|
|
|
DateTime.strptime(datetime, '%s')
|
|
end
|
|
end
|