2017-02-08 17:34:05 -06:00
|
|
|
# frozen_string_literal: true
|
|
|
|
class ReviewerReminder
|
|
|
|
def initialize
|
|
|
|
@collection = reminder_collection
|
|
|
|
end
|
|
|
|
|
|
|
|
def count
|
|
|
|
@collection.count
|
|
|
|
end
|
|
|
|
alias size count
|
|
|
|
|
|
|
|
def reminders
|
|
|
|
@reminders ||= @collection.to_hash.map { |r| OpenStruct.new(r) }
|
|
|
|
end
|
|
|
|
|
|
|
|
def send_all
|
|
|
|
reminders.each do |reminder|
|
|
|
|
ReviewerMailer.reminder(reminder).deliver_now
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def reminder_collection
|
|
|
|
sql = "select u.name, u.email, c.test_hash, c.project
|
|
|
|
from reviewer_votes rev
|
|
|
|
inner join users u on u.id = rev.user_id
|
|
|
|
inner join candidates c on c.id = rev.candidate_id
|
2017-05-10 17:06:35 -05:00
|
|
|
where rev.vote = 0 and c.review_status = 0
|
2017-02-09 16:27:00 -06:00
|
|
|
and u.role != 'manager' and u.active is not false;"
|
2017-02-08 17:34:05 -06:00
|
|
|
ActiveRecord::Base.connection.exec_query(sql)
|
|
|
|
end
|
|
|
|
end
|