Commit c390551c2d91bf73bded7116075040d26ec8e5b1

Authored by Luke Baker
1 parent d97a67f0

add comments in various places and fix bug

bug was in looking for length < 1000 instead of batchsize
Showing 1 changed file with 7 additions and 2 deletions   Show diff stats
lib/tasks/prune_db.rake
... ... @@ -26,6 +26,8 @@ namespace :prune_db do
26 26 end
27 27 end
28 28  
  29 + # There is a very similar task in the AOI code base as well.
  30 + # Any core changes to this task should probably be reflected there.
29 31 desc "Converts all dates from PT to UTC"
30 32 task :convert_dates_to_utc, [:workerid, :workers] => [:environment] do|t,args|
31 33 args.with_defaults(:workerid => "0", :workers => "1")
... ... @@ -109,6 +111,9 @@ namespace :prune_db do
109 111 batch_size = 10000
110 112 i = 0
111 113 where = ''
  114 + # This is how we split the rows of a table between the various workers
  115 + # so that they don't attempt to work on the same row as another worker.
  116 + # The workerid is any number 0 through workers - 1.
112 117 if args[:workers] > "1"
113 118 where = "WHERE MOD(id, #{args[:workers]}) = #{args[:workerid]}"
114 119 end
... ... @@ -120,7 +125,7 @@ namespace :prune_db do
120 125  
121 126 rows.each do |row|
122 127 updated_values = {}
123   - # delete any value where the value is blank
  128 + # delete any value where the value is blank (just for delayed_jobs)
124 129 row.delete_if {|key, value| value.blank? }
125 130 row.each do |column, value|
126 131 next if column == "id"
... ... @@ -162,7 +167,7 @@ namespace :prune_db do
162 167 end
163 168  
164 169 i+= 1
165   - break if rows.length < 1000
  170 + break if rows.length < batchsize
166 171 end
167 172 print "\n"
168 173 end
... ...