mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-10 17:21:38 -05:00
Remove format from ExportJob.perform_later call
This commit is contained in:
parent
2a960826eb
commit
fb8b2958b6
4 changed files with 11 additions and 23 deletions
|
|
@ -12,7 +12,7 @@ class ExportsController < ApplicationController
|
|||
export_name = "export_from_#{params[:start_at].to_date}_to_#{params[:end_at].to_date}"
|
||||
export = current_user.exports.create(name: export_name, status: :created)
|
||||
|
||||
ExportJob.perform_later(export.id, params[:start_at], params[:end_at], format: params[:format])
|
||||
ExportJob.perform_later(export.id, params[:start_at], params[:end_at])
|
||||
|
||||
redirect_to exports_url, notice: 'Export was successfully initiated. Please wait until it\'s finished.'
|
||||
rescue StandardError => e
|
||||
|
|
|
|||
|
|
@ -3,9 +3,9 @@
|
|||
class ExportJob < ApplicationJob
|
||||
queue_as :exports
|
||||
|
||||
def perform(export_id, start_at, end_at, format: :json)
|
||||
def perform(export_id, start_at, end_at)
|
||||
export = Export.find(export_id)
|
||||
|
||||
Exports::Create.new(export:, start_at:, end_at:, format:).call
|
||||
Exports::Create.new(export:, start_at:, end_at:).call
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,12 +1,11 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Exports::Create
|
||||
def initialize(export:, start_at:, end_at:, format: :json)
|
||||
def initialize(export:, start_at:, end_at:)
|
||||
@export = export
|
||||
@user = export.user
|
||||
@start_at = start_at.to_datetime
|
||||
@end_at = end_at.to_datetime
|
||||
@format = format
|
||||
end
|
||||
|
||||
def call
|
||||
|
|
@ -19,7 +18,7 @@ class Exports::Create
|
|||
Rails.logger.debug "====Exporting #{points.size} points"
|
||||
|
||||
data = ::ExportSerializer.new(points, user.email).call
|
||||
file_path = Rails.root.join('public', 'exports', "#{export.name}.#{format}")
|
||||
file_path = Rails.root.join('public', 'exports', "#{export.name}.json")
|
||||
|
||||
File.open(file_path, 'w') { |file| file.write(data) }
|
||||
|
||||
|
|
@ -36,7 +35,7 @@ class Exports::Create
|
|||
|
||||
private
|
||||
|
||||
attr_reader :user, :export, :start_at, :end_at, :format
|
||||
attr_reader :user, :export, :start_at, :end_at
|
||||
|
||||
def time_framed_points
|
||||
user
|
||||
|
|
@ -61,10 +60,4 @@ class Exports::Create
|
|||
content: "Export \"#{export.name}\" failed: #{error.message}, stacktrace: #{error.backtrace.join("\n")}"
|
||||
).call
|
||||
end
|
||||
|
||||
def process_json_export(points)
|
||||
end
|
||||
|
||||
def process_gpx_export(points)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -3,33 +3,28 @@
|
|||
<div class="w-full">
|
||||
<%= form_with url: points_path, method: :get do |f| %>
|
||||
<div class="flex flex-col md:flex-row md:space-x-4 md:items-end">
|
||||
<div class="w-full md:w-3/12">
|
||||
<div class="w-full md:w-2/6">
|
||||
<div class="flex flex-col space-y-2">
|
||||
<%= f.label :start_at, class: "text-sm font-semibold" %>
|
||||
<%= f.datetime_local_field :start_at, class: "rounded-md w-full", value: @start_at %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="w-full md:w-3/12">
|
||||
<div class="w-full md:w-2/6">
|
||||
<div class="flex flex-col space-y-2">
|
||||
<%= f.label :end_at, class: "text-sm font-semibold" %>
|
||||
<%= f.datetime_local_field :end_at, class: "rounded-md w-full", value: @end_at %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="w-full md:w-1/12">
|
||||
<div class="w-full md:w-2/6">
|
||||
<div class="flex flex-col space-y-2">
|
||||
<%= f.submit "Search", class: "px-4 py-2 bg-blue-500 text-white rounded-md" %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="w-full md:w-2/12">
|
||||
<div class="w-full md:w-2/6">
|
||||
<div class="flex flex-col space-y-2 text-center">
|
||||
<%= link_to 'Export points', exports_path(start_at: @start_at, end_at: @end_at), data: { confirm: "Are you sure?", turbo_confirm: "Are you sure? This will start background process of exporting points withing timeframe, selected between #{@start_at} and #{@end_at}", turbo_method: :post }, class: "px-4 py-2 bg-green-500 text-white rounded-md join-item" %>
|
||||
<%= link_to 'Export points', exports_path(start_at: @start_at, end_at: @end_at), data: { confirm: "Are you sure?", turbo_confirm: "Are you sure? This will start background process of exporting points withing timeframe, selected between #{@start_at} and #{@end_at}", turbo_method: :post }, class: "px-4 py-2 bg-green-500 text-white rounded-md" %>
|
||||
</div>
|
||||
</div>
|
||||
<%# <div class="w-full md:w-2/12"> %>
|
||||
<%# <div class="flex flex-col space-y-2 text-center"> %>
|
||||
<%# <%= link_to 'Export as GPX', exports_path(start_at: @start_at, end_at: @end_at, format: :gpx), data: { confirm: "Are you sure?", turbo_confirm: "Are you sure? This will start background process of exporting points withing timeframe, selected between #{@start_at} and #{@end_at}", turbo_method: :post }, class: "px-4 py-2 bg-green-500 text-white rounded-md join-item" %>
|
||||
<%# </div> %>
|
||||
<%# </div> %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue