Created
May 8, 2013 00:36
-
-
Save JKring/5537343 to your computer and use it in GitHub Desktop.
this was to rectify mislabeled prescreen payments
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
misc_writers = Hash.new(0) | |
adj_writers = [] | |
b.finished_jobs.each do |f| | |
p = Payment.where("prescreened_jobs.#{ f.id }" => {"$ne" => nil }).first | |
if p | |
unless p.prescreened_jobs[f.id.to_s] == 15 | |
if p.paid | |
current_p = Payment.current(p.writer) | |
adding = (15 - p.prescreened_jobs[f.id.to_s]) | |
current_p.misc += adding | |
current_p.save | |
misc_writers[p.writer.email] = misc_writers[p.writer.email] + adding | |
else | |
p.prescreened_jobs[f.id.to_s] = 15 | |
p.save | |
adj_writers << p.writer.email | |
end | |
end | |
end | |
end | |
adj_writers.uniq! | |
puts "Misc Additions" | |
misc_writers.each_pair do |e, p| | |
puts "#{ e }: #{ p }" | |
end | |
puts "Adjusted Payments" | |
puts adj_writers.join ", " |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment