diff options
author | Louise Crow <louise.crow@gmail.com> | 2013-08-20 15:58:11 +0100 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2013-08-20 15:58:11 +0100 |
commit | ce30500cea5c2d6304643bc90ce0c5b36a2f5919 (patch) | |
tree | 92ef48879721d017e7b72e663ef8dbc3d6421fb0 /lib/tasks/temp.rake | |
parent | f757ce4ba02c6621e04a349376aeda1c1cb553a3 (diff) | |
parent | dfb5f97ac44656f0e021b09856e0c54b9fa41b3f (diff) |
Merge branch 'release/0.13'0.13
Conflicts:
locale/bg/app.po
locale/es/app.po
locale/fi/app.po
locale/fr/app.po
locale/fr_CA/app.po
locale/he_IL/app.po
locale/hr/app.po
locale/nb_NO/app.po
locale/nl/app.po
locale/pt_BR/app.po
locale/ro_RO/app.po
locale/sl/app.po
locale/vi/app.po
script/rails-post-deploy
Diffstat (limited to 'lib/tasks/temp.rake')
-rw-r--r-- | lib/tasks/temp.rake | 55 |
1 files changed, 46 insertions, 9 deletions
diff --git a/lib/tasks/temp.rake b/lib/tasks/temp.rake index fcabb23de..f746338f0 100644 --- a/lib/tasks/temp.rake +++ b/lib/tasks/temp.rake @@ -1,5 +1,36 @@ namespace :temp do + desc "Fix the history of requests where the described state doesn't match the latest status value + used by search, by adding an edit event that will correct the latest status" + task :fix_bad_request_states => :environment do + dryrun = ENV['DRYRUN'] != '0' + if dryrun + puts "This is a dryrun" + end + + InfoRequest.find_each() do |info_request| + next if info_request.url_title == 'holding_pen' + last_info_request_event = info_request.info_request_events[-1] + if last_info_request_event.latest_status != info_request.described_state + puts "#{info_request.id} #{info_request.url_title} #{last_info_request_event.latest_status} #{info_request.described_state}" + params = { :script => 'rake temp:fix_bad_request_states', + :user_id => nil, + :old_described_state => info_request.described_state, + :described_state => info_request.described_state + } + if ! dryrun + info_request.info_request_events.create!(:last_described_at => last_info_request_event.described_at + 1.second, + :event_type => 'status_update', + :described_state => info_request.described_state, + :calculated_state => info_request.described_state, + :params => params) + info_request.info_request_events.each{ |event| event.mark_needs_xapian_index } + end + end + + end + end + def disable_duplicate_account(user, count, dryrun) dupe_email = "duplicateemail#{count}@example.com" puts "Updating #{user.email} to #{dupe_email} for user #{user.id}" @@ -13,15 +44,21 @@ namespace :temp do total_messages = 0 messages_to_reparse = 0 IncomingMessage.find_each :include => :foi_attachments do |im| - reparse = im.foi_attachments.any? { |fa| ! File.exists? fa.filepath } - total_messages += 1 - messages_to_reparse += 1 if reparse - if total_messages % 1000 == 0 - puts "Considered #{total_messages} received emails." - end - unless dry_run - im.parse_raw_email! true if reparse - sleep 2 + begin + reparse = im.foi_attachments.any? { |fa| ! File.exists? fa.filepath } + total_messages += 1 + messages_to_reparse += 1 if reparse + if total_messages % 1000 == 0 + puts "Considered #{total_messages} received emails." + end + unless dry_run + im.parse_raw_email! true if reparse + sleep 2 + end + rescue StandardError => e + puts "There was a #{e.class} exception reparsing IncomingMessage with ID #{im.id}" + puts e.backtrace + puts e.message end end message = dry_run ? "Would reparse" : "Reparsed" |