diff --git a/app/models/group.rb b/app/models/group.rb index d0dcf51..22f3dac 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -151,6 +151,9 @@ def is_category? = category? def merge_into(replacement_group) # TODO - also update all the transfers Membership.where(member: self).update_all(member_id: replacement_group.id) + Membership.where(group: self).update_all(group_id: replacement_group.id) + Transfer.where(giver: self).update_all(giver_id: replacement_group.id) + Transfer.where(taker: self).update_all(taker_id: replacement_group.id) self.destroy end diff --git a/app/models/position.rb b/app/models/position.rb index 813eb39..9e5cf91 100644 --- a/app/models/position.rb +++ b/app/models/position.rb @@ -1,6 +1,5 @@ class Position < ApplicationRecord include PgSearch::Model - multisearchable against: [:title] belongs_to :membership diff --git a/app/services/map_group_names.rb b/app/services/map_group_names.rb index ace5297..1e78d3b 100644 --- a/app/services/map_group_names.rb +++ b/app/services/map_group_names.rb @@ -60,13 +60,8 @@ def map_or_return_name(name) # https://en.wikipedia.org/wiki/Australian_Energy_Producers return 'Australian Energy Producers' if name.match?(/\bAPPEA\b|Australian Energy Producers/i) - # Independents - - # return 'Kim for Canberra' if name.match?(/Kim for Canberra/i) - # return 'Helen Haines Campaign' if name.match?(/Helen Haines/i) return 'Liberal Democratic Party' if name.match?(/Liberal.+Democrat/i) - return 'Shooters, Fishers and Farmers Party' if name.match?(/Shooters, Fishers and Farmers/i) return 'Citizens Party' if name.match?(/(Citizens Party|CEC)/i) return 'Sustainable Australia Party' if name.match?(/Sustainable Australia/i) @@ -77,8 +72,7 @@ def map_or_return_name(name) return 'Federal Independents' if name.match?(/Independent Fed/i) return 'Waringah Independents' if name.match?(/(Warringah|Waringah).+(independent|Independant)/i) return 'Lambie Network' if name.match?(/Lambie/i) - return 'United Australia Party' if name.match?(/United Australia Party/i) - + return 'United Australia Party' if name.match?(/United Australia (Party|Federal)/i) return "Pauline Hanson's One Nation" if name.match?(/Pauline Hanson|One Nation/i) # specific exceptions diff --git a/lib/tasks/add_records.rake b/lib/tasks/add_records.rake index ba62b80..97b52f9 100644 --- a/lib/tasks/add_records.rake +++ b/lib/tasks/add_records.rake @@ -24,8 +24,8 @@ namespace :lester do end lobbyists = [ - 'csv_data/lobbyists_2024-11-04.csv', - 'csv_data/lobyyists_2024-11-05.csv', + # 'csv_data/lobbyists_2024-11-04.csv', + # 'csv_data/lobyyists_2024-11-05.csv', ] lobbyists.each do |file| diff --git a/lib/tasks/maintenance.rake b/lib/tasks/maintenance.rake index 496063e..c12f306 100644 --- a/lib/tasks/maintenance.rake +++ b/lib/tasks/maintenance.rake @@ -11,11 +11,17 @@ namespace :lester do end desc "Remove Duplicates" - task remove_duplicates: :environment do + task merge_duplicates: :environment do ## MERGING EXAMPLE ## # ey = Group.find_by(name: 'EY') # ernst_and_young = Group.find_by(name: 'Ernst & Young') # ey.merge_into(ernst_and_young) + + ralph_party = Group.find_by(name: 'United Australia Federal') + clive_party = Group.find_by(name: 'United Australia Party') + print "Merging #{ralph_party.name} into #{clive_party.name}... " + ralph_party.merge_into(clive_party) + puts "done." end desc "Add time range for party memberships" diff --git a/spec/services/record_group_spec.rb b/spec/services/record_group_spec.rb index 6ef44b2..9ba3011 100644 --- a/spec/services/record_group_spec.rb +++ b/spec/services/record_group_spec.rb @@ -187,16 +187,6 @@ 'Australian Conservatives (Qld)' => 'Australian Conservatives', 'Australian Conservatives (Vic)' => 'Australian Conservatives', 'Australian Conservatives ACP' => 'Australian Conservatives', - # Independents - # 'David Pocock' => 'David Pocock Campaign', - # 'David Pocock - Davi' => 'David Pocock Campaign', - # 'David Pocock Campaign' => 'David Pocock Campaign', - # 'David Pocock Pty Ltd' => 'David Pocock Campaign', - # 'David Pocock/DAVI' => 'David Pocock Campaign', - # 'Zali Steggall' => 'Zali Steggall Campaign', - # 'Zali Steggall Campaign' => 'Zali Steggall Campaign', - # 'Kim for Canberra' => 'Kim for Canberra', - # 'Helen Haines' => 'Helen Haines Campaign', # Other 'climate 200 Pty Ltd' => 'Climate 200 Pty Ltd', 'climate 200 pty ltd' => 'Climate 200 Pty Ltd', @@ -224,6 +214,8 @@ 'GetUp Ltd' => 'Get Up Limited', 'Alpha Diversification Pty Ltd' => 'Alpha Diversification Pty Ltd', 'Actus Services Pty Ltd' => 'Actus Services Pty Ltd', + 'United Australia Party' => 'United Australia Party', + 'United Australia Federal' => 'United Australia Party', } end