Browse Source

Add scheme_id back to DUPLICATE_LOCATION_ATTRIBUTES

pull/2645/head
Kat 2 years ago
parent
commit
409203f630
  1. 5
      app/models/location.rb
  2. 2
      lib/tasks/count_duplicates.rake

5
app/models/location.rb

@ -133,10 +133,9 @@ class Location < ApplicationRecord
scope.pluck("ARRAY_AGG(id)")
}
scope :duplicate_sets_within_duplicate_schemes, lambda {
scope :duplicate_sets_within_given_schemes, lambda {
scope = visible
.group(*DUPLICATE_LOCATION_ATTRIBUTES - %w[scheme_id])
.where(scheme_id: nil)
.where.not(postcode: nil)
.where.not(mobility_type: nil)
.having(
@ -145,7 +144,7 @@ class Location < ApplicationRecord
scope.pluck("ARRAY_AGG(id)")
}
DUPLICATE_LOCATION_ATTRIBUTES = %w[postcode mobility_type].freeze
DUPLICATE_LOCATION_ATTRIBUTES = %w[scheme_id postcode mobility_type].freeze
LOCAL_AUTHORITIES = LocalAuthority.all.map { |la| [la.name, la.code] }.to_h
enum local_authorities: LOCAL_AUTHORITIES

2
lib/tasks/count_duplicates.rake

@ -35,7 +35,7 @@ namespace :count_duplicates do
duplicate_sets_within_duplicate_schemes = []
if organisation.owned_schemes.duplicate_sets.count.positive?
organisation.owned_schemes.duplicate_sets.each do |duplicate_set|
duplicate_sets_within_duplicate_schemes += Location.where(scheme_id: duplicate_set).duplicate_sets
duplicate_sets_within_duplicate_schemes += Location.where(scheme_id: duplicate_set).duplicate_sets_within_given_schemes
end
duplicate_locations_within_duplicate_schemes_ids = duplicate_sets_within_duplicate_schemes.flatten

Loading…
Cancel
Save