Browse Source

Update scopes

CLDC-1324-remove-not-started
Jack S 2 years ago
parent
commit
0bd29031bc
  1. 16
      app/models/log.rb
  2. 2
      app/services/bulk_upload/lettings/year2022/row_parser.rb
  3. 2
      app/services/bulk_upload/sales/year2022/row_parser.rb

16
app/models/log.rb

@ -20,8 +20,20 @@ class Log < ApplicationRecord
enum status: STATUS
enum status_cache: STATUS, _prefix: true
scope :visible, -> { where(status: %w[not_started in_progress completed]) }
scope :exportable, -> { where(status: %w[not_started in_progress completed deleted]) }
scope :visible, lambda {
if FeatureToggle.not_started_status_removed?
where(status: %w[in_progress completed])
else
where(status: %w[not_started in_progress completed])
end
}
scope :exportable, lambda {
if FeatureToggle.not_started_status_removed?
where(status: %w[in_progress completed deleted])
else
where(status: %w[not_started in_progress completed deleted])
end
}
scope :filter_by_status, ->(status, _user = nil) { where status: }
scope :filter_by_years, lambda { |years, _user = nil|

2
app/services/bulk_upload/lettings/year2022/row_parser.rb

@ -434,7 +434,7 @@ class BulkUpload::Lettings::Year2022::RowParser
def log_already_exists?
@log_already_exists ||= LettingsLog
.where(status: %w[not_started in_progress completed])
.visible
.exists?(duplicate_check_fields.index_with { |field| log.public_send(field) })
end

2
app/services/bulk_upload/sales/year2022/row_parser.rb

@ -340,7 +340,7 @@ class BulkUpload::Sales::Year2022::RowParser
def log_already_exists?
@log_already_exists ||= SalesLog
.where(status: %w[not_started in_progress completed])
.visible
.exists?(duplicate_check_fields.index_with { |field| log.public_send(field) })
end

Loading…
Cancel
Save