Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect days in email subject and content #19

Open
Benniu opened this issue Jul 5, 2011 · 1 comment
Open

Incorrect days in email subject and content #19

Benniu opened this issue Jul 5, 2011 · 1 comment

Comments

@Benniu
Copy link

Benniu commented Jul 5, 2011

Hi, Chantra

I installed redmine_whining in my redmine. The email sending is working fine. But I found an issue:

In our configration, P1 bugs will whine after 1 day. P2/P3 bugs will whine after 2 days. And P4 bugs will whine after 7 days.

If a P2 bug is not updated within 2 days, the email will be send to the assignee, that is correct.
But in this email, it is saying that the issue assigned to you haven't been updated in the last 7 days.

I thinks this is because the days passed to deliver_whining method is get from the rake command not from the setting configuration.
I would suggest sending emails group by both assignee and delay days

Hope it could be fixed.

Thanks,
Benniu

@Benniu
Copy link
Author

Benniu commented Jul 5, 2011

I resolve this issue by the following code change:

def self.whinings(options={})
days = options[:days] || 7

projects = EnabledModule.find(:all, :conditions => ["name = 'whining'"]).collect { |mod| mod.project_id }
return if projects.length == 0

sql = []
params = []
IssuePriority.find(:all).each { |prio|
    delay = Setting.plugin_redmine_whining["delay_#{prio.id}".intern]
    delay = Setting.plugin_redmine_whining[:delay_default] if not delay
    delay = Integer(delay).day.until.to_date
    #delay += 1 if delay.wday == 0
    #delay += 2 if delay.wday == 6

    sql << "(#{Issue.table_name}.priority_id = ? AND #{Issue.table_name}.updated_on <= ?)"
    params << prio.id
    params << delay
}

sql = "(#{sql.join(' OR ')}) AND #{IssueStatus.table_name}.is_closed = ? AND #{Issue.table_name}.assigned_to_id IS NOT NULL"
params << false

s = ARCondition.new [sql] + params

s << "#{Issue.table_name}.project_id in (#{projects.join(",")})"
trackers = Setting.plugin_redmine_whining[:trackers]
s << "#{Issue.table_name}.tracker_id in (#{trackers.join(",")})" if trackers && trackers.length > 0
issues_by_assignee = Issue.find(:all, 
                                :include => [:status, :assigned_to, :project, :tracker, :priority],
                                :conditions => s.conditions
                                ).group_by(&:assigned_to)


issues_by_assignee.each do |assignee, issues|

  issues_by_priority = issues.group_by(&:priority)

  issues_by_priority.each do |priority, p_issues|

    delay = Setting.plugin_redmine_whining["delay_#{priority.id}".intern]
    delay = Setting.plugin_redmine_whining[:delay_default] if not delay

    deliver_whining(assignee, p_issues, delay) unless assignee.nil?
  end

end

end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant