Skip to content

Commit

Permalink
Merge pull request #31 from johnofsydney/fix-search
Browse files Browse the repository at this point in the history
Stop Search on Position
  • Loading branch information
johnofsydney authored Nov 12, 2024
2 parents 72c9ef9 + cbe08a6 commit feea487
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 21 deletions.
3 changes: 3 additions & 0 deletions app/models/group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion app/models/position.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
class Position < ApplicationRecord
include PgSearch::Model
multisearchable against: [:title]

belongs_to :membership

Expand Down
8 changes: 1 addition & 7 deletions app/services/map_group_names.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/tasks/add_records.rake
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down
8 changes: 7 additions & 1 deletion lib/tasks/maintenance.rake
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
12 changes: 2 additions & 10 deletions spec/services/record_group_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit feea487

Please sign in to comment.