Project

General

Profile

Feature #28638 » mailer.rb.patch

Davide Giacometti, 2018-04-26 12:03

View differences:

app/models/mailer.rb
378 378
  # Available options:
379 379
  # * :days     => how many days in the future to remind about (defaults to 7)
380 380
  # * :tracker  => id of tracker for filtering issues (defaults to all trackers)
381
  # * :statuses => comma separated list of issue_statuses ids (defaults to all issue_statuses)
381 382
  # * :project  => id or identifier of project to process (defaults to all projects)
382 383
  # * :users    => array of user/group ids who should be reminded
383 384
  # * :version  => name of target version for filtering issues (defaults to none)
......
385 386
    days = options[:days] || 7
386 387
    project = options[:project] ? Project.find(options[:project]) : nil
387 388
    tracker = options[:tracker] ? Tracker.find(options[:tracker]) : nil
389
    status = options[:status] ? IssueStatus.find(options[:status]) : nil
388 390
    target_version_id = options[:version] ? Version.named(options[:version]).pluck(:id) : nil
389 391
    if options[:version] && target_version_id.blank?
390 392
      raise ActiveRecord::RecordNotFound.new("Couldn't find Version named #{options[:version]}")
391 393
    end
392 394
    user_ids = options[:users]
395
    issue_statuses_ids = options[:statuses]
393 396

  
394 397
    scope = Issue.open.where("#{Issue.table_name}.assigned_to_id IS NOT NULL" +
395 398
      " AND #{Project.table_name}.status = #{Project::STATUS_ACTIVE}" +
396 399
      " AND #{Issue.table_name}.due_date <= ?", days.day.from_now.to_date
397 400
    )
398 401
    scope = scope.where(:assigned_to_id => user_ids) if user_ids.present?
402
    scope = scope.where(:status_id => issue_statuses_ids) if issue_statuses_ids.present?
399 403
    scope = scope.where(:project_id => project.id) if project
400 404
    scope = scope.where(:fixed_version_id => target_version_id) if target_version_id.present?
401 405
    scope = scope.where(:tracker_id => tracker.id) if tracker
(1-1/2)