class DelayExpiredIssueAndMilestoneJob < ApplicationJob
  queue_as :message

  def perform
    Issue.where(due_date: Date.today + 1.days).find_each do |issue|
      SendTemplateMessageJob.perform_later('IssueExpire', issue.id) if Site.has_notice_menu?
    end
    Version.where(effective_date: Date.today + 1.days).find_each do |version| 
      SendTemplateMessageJob.perform_later('ProjectMilestoneEarlyExpired', version.id) if Site.has_notice_menu?
    end
    Version.where(effective_date: Date.today - 1.days).find_each do |version|
      SendTemplateMessageJob.perform_later('ProjectMilestoneExpired', version.id) if Site.has_notice_menu?
    end
  end

end