Browse Source

feat: simplify and refactor

CLDC-3025-leading-zeroes-in-old-visible-id-lookup-bug
natdeanlewissoftwire 1 year ago
parent
commit
f29507189a
  1. 8
      app/helpers/duplicate_logs_helper.rb
  2. 17
      app/models/organisation.rb
  3. 16
      app/models/user.rb

8
app/helpers/duplicate_logs_helper.rb

@ -33,15 +33,15 @@ module DuplicateLogsHelper
def duplicates_for_user(user) def duplicates_for_user(user)
{ {
lettings: user.duplicate_lettings_logs_sets, lettings: user.editable_duplicate_lettings_logs_sets,
sales: user.duplicate_sales_logs_sets, sales: user.editable_duplicate_sales_logs_sets,
} }
end end
def duplicates_for_organisation(organisation) def duplicates_for_organisation(organisation)
{ {
lettings: organisation.duplicate_lettings_logs_sets, lettings: organisation.editable_duplicate_lettings_logs_sets,
sales: organisation.duplicate_sales_logs_sets, sales: organisation.editable_duplicate_sales_logs_sets,
} }
end end

17
app/models/organisation.rb

@ -134,22 +134,15 @@ class Organisation < ApplicationRecord
end end
def editable_duplicate_lettings_logs_sets def editable_duplicate_lettings_logs_sets
all_sets = lettings_logs.duplicate_sets.map { |array_str| array_str ? array_str.map(&:to_i) : [] } lettings_logs.duplicate_sets.map { |array_str| array_str ? array_str.map(&:to_i) : [] }
editable_sets = [] .select { |set| LettingsLog.find(set.first).collection_period_open_for_editing? }
all_sets.each do |set|
editable_sets << set if LettingsLog.find(set.first).collection_period_open_for_editing?
end
editable_sets
end end
def editable_duplicate_sales_logs_sets def editable_duplicate_sales_logs_sets
all_sets = sales_logs.duplicate_sets.map { |array_str| array_str ? array_str.map(&:to_i) : [] } sales_logs.duplicate_sets.map { |array_str| array_str ? array_str.map(&:to_i) : [] }
editable_sets = [] .select { |set| SalesLog.find(set.first).collection_period_open_for_editing? }
all_sets.each do |set|
editable_sets << set if SalesLog.find(set.first).collection_period_open_for_editing?
end
editable_sets
end end
def recently_absorbed_organisations_grouped_by_merge_date def recently_absorbed_organisations_grouped_by_merge_date
return unless absorbed_organisations.present? && absorbed_organisations.merged_during_open_collection_period.present? return unless absorbed_organisations.present? && absorbed_organisations.merged_during_open_collection_period.present?

16
app/models/user.rb

@ -204,21 +204,13 @@ class User < ApplicationRecord
end end
def editable_duplicate_lettings_logs_sets def editable_duplicate_lettings_logs_sets
all_sets = lettings_logs.duplicate_sets(id).map { |array_str| array_str ? array_str.map(&:to_i) : [] } lettings_logs.duplicate_sets(id).map { |array_str| array_str ? array_str.map(&:to_i) : [] }
editable_sets = [] .select { |set| LettingsLog.find(set.first).collection_period_open_for_editing? }
all_sets.each do |set|
editable_sets << set if LettingsLog.find(set.first).collection_period_open_for_editing?
end
editable_sets
end end
def editable_duplicate_sales_logs_sets def editable_duplicate_sales_logs_sets
all_sets = sales_logs.duplicate_sets(id).map { |array_str| array_str ? array_str.map(&:to_i) : [] } sales_logs.duplicate_sets(id).map { |array_str| array_str ? array_str.map(&:to_i) : [] }
editable_sets = [] .select { |set| SalesLog.find(set.first).collection_period_open_for_editing? }
all_sets.each do |set|
editable_sets << set if SalesLog.find(set.first).collection_period_open_for_editing?
end
editable_sets
end end
protected protected

Loading…
Cancel
Save