Browse Source

fixup! CLDC-4119: Update main site duplicate logs check

handle sexrab answered properly
CLDC-4119-amend-lettings-duplicate-log-check
samyou-softwire 2 days ago
parent
commit
840d7d29ef
  1. 5
      app/models/lettings_log.rb
  2. 2
      lib/tasks/handle_unpended_logs.rake

5
app/models/lettings_log.rb

@ -98,11 +98,12 @@ class LettingsLog < Log
}
scope :location_answered, -> { where.not(location_id: nil).or(where(needstype: 1)).or(filter_by_year_or_later(2026)) }
scope :postcode_answered, -> { where.not(postcode_full: nil).or(where(needstype: 2)) }
scope :sex1_answered, -> { where.not(sex1: nil).filter_by_year_or_earlier(2025).or(where.not(sexrab1: nil).filter_by_year_or_later(2026)) }
scope :duplicate_logs, lambda { |log|
visible
.where.not(id: log.id)
.where.not(startdate: nil)
.where.not(sex1: nil)
.sex1_answered
.where.not(ecstat1: nil)
.where.not(needstype: nil)
.age1_answered
@ -142,7 +143,7 @@ class LettingsLog < Log
# separate function as location needs to be fully ignored in 2026
.group(*DUPLICATE_LOG_ATTRIBUTES, :postcode_full, :uprn, :address_line1)
.where.not(startdate: nil)
.where.not(sex1: nil)
.where.not(sexrab1: nil)
.where.not(ecstat1: nil)
.where.not(needstype: nil)
.age1_answered

2
lib/tasks/handle_unpended_logs.rake

@ -41,7 +41,7 @@ task :handle_unpended_logs, %i[perform_updates] => :environment do |_task, args|
# This is the normal query for duplicates but without the check that the logs are visible (i.e. not deleted/pending)
duplicates = LettingsLog.where.not(id: log.id)
.where.not(startdate: nil)
.where.not(sex1: nil)
.sex1_answered
.where.not(ecstat1: nil)
.where.not(needstype: nil)
.age1_answered

Loading…
Cancel
Save