Rename format column to file_format in exports table

This commit is contained in:
Eugene Burmakin 2025-04-02 21:19:02 +02:00
parent 6b473edb86
commit 2f9cacba61
10 changed files with 9 additions and 10 deletions

View file

@ -14,7 +14,7 @@ class ExportsController < ApplicationController
export = current_user.exports.create(
name: export_name,
status: :created,
format: params[:file_format],
file_format: params[:file_format],
start_at: params[:start_at],
end_at: params[:end_at]
)

View file

@ -4,7 +4,7 @@ class Export < ApplicationRecord
belongs_to :user
enum :status, { created: 0, processing: 1, completed: 2, failed: 3 }
enum :format, { json: 0, gpx: 1 }
enum :file_format, { json: 0, gpx: 1 }
validates :name, presence: true

View file

@ -6,7 +6,7 @@ class Exports::Create
@user = export.user
@start_at = export.start_at
@end_at = export.end_at
@file_format = export.format
@file_format = export.file_format
end
def call

View file

@ -1 +0,0 @@
41976cfff86107bc1bb52cec7d8107b0

View file

@ -43,7 +43,7 @@ Rails.application.configure do
# config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX
# Store uploaded files on the local file system (see config/storage.yml for options).
config.active_storage.service = :local
config.active_storage.service = ENV['SELF_HOSTED'] == 'true' ? :local : :s3
config.silence_healthcheck_path = '/api/v1/health'

View file

@ -2,7 +2,7 @@
class AddFormatStartAtEndAtToExports < ActiveRecord::Migration[8.0]
def change
add_column :exports, :format, :integer, default: 0
add_column :exports, :file_format, :integer, default: 0
add_column :exports, :start_at, :datetime
add_column :exports, :end_at, :datetime
end

2
db/schema.rb generated
View file

@ -74,7 +74,7 @@ ActiveRecord::Schema[8.0].define(version: 2025_03_24_180755) do
t.bigint "user_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "format", default: 0
t.integer "file_format", default: 0
t.datetime "start_at"
t.datetime "end_at"
t.index ["status"], name: "index_exports_on_status"

View file

@ -4,7 +4,7 @@ FactoryBot.define do
factory :export do
name { 'export' }
status { :created }
format { :json }
file_format { :json }
user
end
end

View file

@ -9,6 +9,6 @@ RSpec.describe Export, type: :model do
describe 'enums' do
it { is_expected.to define_enum_for(:status).with_values(created: 0, processing: 1, completed: 2, failed: 3) }
it { is_expected.to define_enum_for(:format).with_values(json: 0, gpx: 1) }
it { is_expected.to define_enum_for(:file_format).with_values(json: 0, gpx: 1) }
end
end

View file

@ -12,7 +12,7 @@ RSpec.describe Exports::Create do
let(:end_at) { DateTime.new(2021, 1, 2).to_s }
let(:export_name) { "#{start_at.to_date}_#{end_at.to_date}.#{file_format}" }
let(:export) do
create(:export, user:, name: export_name, status: :created, format: file_format, start_at:, end_at:)
create(:export, user:, name: export_name, status: :created, file_format: file_format, start_at:, end_at:)
end
let(:export_content) { Points::GeojsonSerializer.new(points).call }
let(:reverse_geocoded_at) { Time.zone.local(2021, 1, 1) }