Project

General

Profile

Email notifications

Added by Zed Zed almost 16 years ago

Hi, I'd like to setup a set of rake tasks that will send out emails ~15 minutes before an issue is due but only send out emails once for each ticket. Is there a part of the Issue database that I can use to hold if an email has been sent? How would I alter the database if not?

Thanks

going to alter this:

  1. Sends reminders to issue assignees
  2. Available options:
  3. * :days => how many days in the future to remind about (defaults to 7)
  4. * :tracker => id of tracker for filtering issues (defaults to all trackers)
  5. * :project => id or identifier of project to process (defaults to all projects)
    def self.reminders(options={})
    days = options[:days] || 7
    project = options[:project] ? Project.find(options[:project]) : nil
    tracker = options[:tracker] ? Tracker.find(options[:tracker]) : nil

    s = ARCondition.new ["#{IssueStatus.table_name}.is_closed = ? AND #{Issue.table_name}.due_date <= ?", false, days.day.from_now.to_date]
    s << "#{Issue.table_name}.assigned_to_id IS NOT NULL"
    s << "#{Project.table_name}.status = #{Project::STATUS_ACTIVE}"
    s << "#{Issue.table_name}.project_id = #{project.id}" if project
    s << "#{Issue.table_name}.tracker_id = #{tracker.id}" if tracker

    issues_by_assignee = Issue.find(:all, :include => [:status, :assigned_to, :project, :tracker],
    :conditions => s.conditions
    ).group_by(&:assigned_to)
    issues_by_assignee.each do |assignee, issues|
    deliver_reminder(assignee, issues, days) unless assignee.nil?
    end
    end