2024-04-26 12:59:58 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
2024-03-23 16:46:18 -04:00
|
|
|
class ExportController < ApplicationController
|
|
|
|
|
before_action :authenticate_user!
|
|
|
|
|
|
|
|
|
|
def index
|
|
|
|
|
@export = current_user.export_data
|
|
|
|
|
end
|
2024-04-04 11:29:11 -04:00
|
|
|
|
|
|
|
|
def download
|
|
|
|
|
export = current_user.export_data
|
|
|
|
|
|
2024-04-26 12:59:58 -04:00
|
|
|
send_data export, filename:
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
|
|
def filename
|
|
|
|
|
first_point_datetime = Time.zone.at(current_user.points.first.timestamp).to_s
|
|
|
|
|
last_point_datetime = Time.zone.at(current_user.points.last.timestamp).to_s
|
|
|
|
|
|
|
|
|
|
"dawarich-export-#{first_point_datetime}-#{last_point_datetime}.json".gsub(' ', '_')
|
2024-04-04 11:29:11 -04:00
|
|
|
end
|
2024-03-23 16:46:18 -04:00
|
|
|
end
|