aboutsummaryrefslogtreecommitdiffstats
path: root/lib/tasks
diff options
context:
space:
mode:
Diffstat (limited to 'lib/tasks')
-rw-r--r--lib/tasks/temp.rake30
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/tasks/temp.rake b/lib/tasks/temp.rake
index fcabb23de..5dba4fb7a 100644
--- a/lib/tasks/temp.rake
+++ b/lib/tasks/temp.rake
@@ -1,5 +1,35 @@
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)
+ 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}"