mirror of
https://github.com/mastodon/mastodon.git
synced 2024-08-20 21:08:15 -07:00
Use enum-generated scopes/queries for BulkImport
(#29975)
This commit is contained in:
parent
630572323f
commit
11e0049b08
6 changed files with 9 additions and 9 deletions
|
@ -31,7 +31,7 @@ class Settings::ImportsController < Settings::BaseController
|
|||
def show; end
|
||||
|
||||
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|
|
||||
format.csv do
|
||||
|
@ -92,7 +92,7 @@ class Settings::ImportsController < Settings::BaseController
|
|||
end
|
||||
|
||||
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
|
||||
|
||||
def set_recent_imports
|
||||
|
|
|
@ -9,7 +9,7 @@ class Vacuum::ImportsVacuum
|
|||
private
|
||||
|
||||
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
|
||||
|
||||
def clean_old_imports!
|
||||
|
|
|
@ -38,7 +38,7 @@ class BulkImport < ApplicationRecord
|
|||
scheduled: 1,
|
||||
in_progress: 2,
|
||||
finished: 3,
|
||||
}
|
||||
}, prefix: true
|
||||
|
||||
validates :type, presence: true
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
%tr
|
||||
%td= t("imports.types.#{import.type}")
|
||||
%td
|
||||
- if import.unconfirmed?
|
||||
- if import.state_unconfirmed?
|
||||
= link_to t("imports.states.#{import.state}"), settings_import_path(import)
|
||||
- else
|
||||
= t("imports.states.#{import.state}")
|
||||
|
@ -59,7 +59,7 @@
|
|||
%td
|
||||
- num_failed = import.processed_items - import.imported_items
|
||||
- if num_failed.positive?
|
||||
- if import.finished?
|
||||
- if import.state_finished?
|
||||
= link_to num_failed, failures_settings_import_path(import, format: 'csv')
|
||||
- else
|
||||
= num_failed
|
||||
|
|
|
@ -281,7 +281,7 @@ RSpec.describe Form::Import do
|
|||
end
|
||||
|
||||
it 'defaults to unconfirmed true' do
|
||||
expect(bulk_import.unconfirmed?).to be true
|
||||
expect(bulk_import.state_unconfirmed?).to be true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -291,7 +291,7 @@ RSpec.describe BulkImportService do
|
|||
|
||||
it 'marks the import as finished' do
|
||||
subject.call(import)
|
||||
expect(import.reload.finished?).to be true
|
||||
expect(import.reload.state_finished?).to be true
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -319,7 +319,7 @@ RSpec.describe BulkImportService do
|
|||
|
||||
it 'marks the import as finished' do
|
||||
subject.call(import)
|
||||
expect(import.reload.finished?).to be true
|
||||
expect(import.reload.state_finished?).to be true
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue