Skip to content

Commit

Permalink
Shallower if trees in update_cwc_code task
Browse files Browse the repository at this point in the history
  • Loading branch information
k-stewart committed May 21, 2018
1 parent 69ec7c2 commit c5f15a6
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions tasks/phantom-dc.rake
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,20 @@ namespace :'phantom-dc' do
desc "Update CWC office codes. Run once after switching to CWC delivery."
task :update_cwc_codes do |t, args|
CongressMember.all.each do |cm|
if term = get_legislator_info(cm.bioguide_id)["terms"].try(:last)
if term["type"] == "sen"
cm.chamber = "senate"
cm.senate_class = term["class"]
cm.house_district = nil
else
cm.chamber = "house"
cm.house_district = term["district"]
cm.senate_class = nil
end
cm.state = term["state"]
cm.save
next unless (term = get_legislator_info(cm.bioguide_id)["terms"].try(:last))

if term["type"] == "sen"
cm.chamber = "senate"
cm.senate_class = term["class"]
cm.house_district = nil
else
cm.chamber = "house"
cm.house_district = term["district"]
cm.senate_class = nil
end

cm.state = term["state"]
cm.save
end
end

Expand Down

0 comments on commit c5f15a6

Please sign in to comment.