Browse Source

Mobbing changes

pull/587/head
Stéphane Meny 3 years ago
parent
commit
8a37b4894d
No known key found for this signature in database
GPG Key ID: 9D0AFEA988527923
  1. 8
      app/services/exports/case_log_export_service.rb

8
app/services/exports/case_log_export_service.rb

@ -25,10 +25,13 @@ module Exports
def save_export_run def save_export_run
today = Time.zone.today today = Time.zone.today
last_daily_run_number = LogsExport.where(created_at: today.beginning_of_day..today.end_of_day).maximum(:daily_run_number) last_daily_run_number = LogsExport.where(created_at: today.beginning_of_day..today.end_of_day).maximum(:daily_run_number)
last_daily_run_number = 0 if last_daily_run_number.nil?
export = LogsExport.new export = LogsExport.new
if last_daily_run_number.nil?
export.daily_run_number = 1
else
export.daily_run_number = last_daily_run_number + 1 export.daily_run_number = last_daily_run_number + 1
end
export.save! export.save!
export export
end end
@ -38,7 +41,7 @@ module Exports
increment_number = export.daily_run_number.to_s.rjust(4, "0") increment_number = export.daily_run_number.to_s.rjust(4, "0")
month = today.month.to_s.rjust(2, "0") month = today.month.to_s.rjust(2, "0")
day = today.day.to_s.rjust(2, "0") day = today.day.to_s.rjust(2, "0")
file_path = "Manifest_#{today.year}_#{month}_#{day}_#{increment_number}.csv" file_path = "Manifest_#{today.year}-#{month}-#{day}_#{increment_number}.csv"
string_io = build_manifest_csv_io string_io = build_manifest_csv_io
@storage_service.write_file(file_path, string_io) @storage_service.write_file(file_path, string_io)
end end
@ -50,6 +53,7 @@ module Exports
end end
def retrieve_case_logs def retrieve_case_logs
# All logs from previous (successful) start time to current start time (not current) [ignore status]
params = { from: Time.current.beginning_of_day, to: Time.current, status: CaseLog.statuses[:completed] } params = { from: Time.current.beginning_of_day, to: Time.current, status: CaseLog.statuses[:completed] }
CaseLog.where("updated_at >= :from and updated_at <= :to and status = :status", params) CaseLog.where("updated_at >= :from and updated_at <= :to and status = :status", params)
end end

Loading…
Cancel
Save