Use enum-generated scopes/queries for `BulkImport` (#29975)
parent
630572323f
commit
11e0049b08
|
@ -31,7 +31,7 @@ class Settings::ImportsController < Settings::BaseController
|
||||||
def show; end
|
def show; end
|
||||||
|
|
||||||
def failures
|
def failures
|
||||||
@bulk_import = current_account.bulk_imports.where(state: :finished).find(params[:id])
|
@bulk_import = current_account.bulk_imports.state_finished.find(params[:id])
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.csv do
|
format.csv do
|
||||||
|
@ -92,7 +92,7 @@ class Settings::ImportsController < Settings::BaseController
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_bulk_import
|
def set_bulk_import
|
||||||
@bulk_import = current_account.bulk_imports.where(state: :unconfirmed).find(params[:id])
|
@bulk_import = current_account.bulk_imports.state_unconfirmed.find(params[:id])
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_recent_imports
|
def set_recent_imports
|
||||||
|
|
|
@ -9,7 +9,7 @@ class Vacuum::ImportsVacuum
|
||||||
private
|
private
|
||||||
|
|
||||||
def clean_unconfirmed_imports!
|
def clean_unconfirmed_imports!
|
||||||
BulkImport.where(state: :unconfirmed).where('created_at <= ?', 10.minutes.ago).reorder(nil).in_batches.delete_all
|
BulkImport.state_unconfirmed.where('created_at <= ?', 10.minutes.ago).reorder(nil).in_batches.delete_all
|
||||||
end
|
end
|
||||||
|
|
||||||
def clean_old_imports!
|
def clean_old_imports!
|
||||||
|
|
|
@ -38,7 +38,7 @@ class BulkImport < ApplicationRecord
|
||||||
scheduled: 1,
|
scheduled: 1,
|
||||||
in_progress: 2,
|
in_progress: 2,
|
||||||
finished: 3,
|
finished: 3,
|
||||||
}
|
}, prefix: true
|
||||||
|
|
||||||
validates :type, presence: true
|
validates :type, presence: true
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@
|
||||||
%tr
|
%tr
|
||||||
%td= t("imports.types.#{import.type}")
|
%td= t("imports.types.#{import.type}")
|
||||||
%td
|
%td
|
||||||
- if import.unconfirmed?
|
- if import.state_unconfirmed?
|
||||||
= link_to t("imports.states.#{import.state}"), settings_import_path(import)
|
= link_to t("imports.states.#{import.state}"), settings_import_path(import)
|
||||||
- else
|
- else
|
||||||
= t("imports.states.#{import.state}")
|
= t("imports.states.#{import.state}")
|
||||||
|
@ -59,7 +59,7 @@
|
||||||
%td
|
%td
|
||||||
- num_failed = import.processed_items - import.imported_items
|
- num_failed = import.processed_items - import.imported_items
|
||||||
- if num_failed.positive?
|
- if num_failed.positive?
|
||||||
- if import.finished?
|
- if import.state_finished?
|
||||||
= link_to num_failed, failures_settings_import_path(import, format: 'csv')
|
= link_to num_failed, failures_settings_import_path(import, format: 'csv')
|
||||||
- else
|
- else
|
||||||
= num_failed
|
= num_failed
|
||||||
|
|
|
@ -281,7 +281,7 @@ RSpec.describe Form::Import do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'defaults to unconfirmed true' do
|
it 'defaults to unconfirmed true' do
|
||||||
expect(bulk_import.unconfirmed?).to be true
|
expect(bulk_import.state_unconfirmed?).to be true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -291,7 +291,7 @@ RSpec.describe BulkImportService do
|
||||||
|
|
||||||
it 'marks the import as finished' do
|
it 'marks the import as finished' do
|
||||||
subject.call(import)
|
subject.call(import)
|
||||||
expect(import.reload.finished?).to be true
|
expect(import.reload.state_finished?).to be true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -319,7 +319,7 @@ RSpec.describe BulkImportService do
|
||||||
|
|
||||||
it 'marks the import as finished' do
|
it 'marks the import as finished' do
|
||||||
subject.call(import)
|
subject.call(import)
|
||||||
expect(import.reload.finished?).to be true
|
expect(import.reload.state_finished?).to be true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue