anteo / redmine_custom_workflows

Allows to create custom workflows for Redmine
http://www.redmine.org/plugins/custom-workflows
GNU General Public License v2.0
182 stars 72 forks source link

change Issue priorities depend the due date #177

Closed ashrafalzyoud closed 4 years ago

ashrafalzyoud commented 4 years ago

i need formula if cfs [10] type date if (date.today - cfs [10] ) result=> 7 days set --> enumerations =1 (low) if (date.today - cfs [10] ) result=(0-7 days) set --> enumerations =1 (normal) if (date.today - cfs [10] ) result=<0 days set ---> enumerations =2 (high) when issue close set --->enumerations= 1 ( low )

ashrafalzyoud commented 4 years ago

@AirTibu if u can help me

AirTibu commented 4 years ago

Hi,

Add this code to BEFORE SAVE section:

if self.custom_field_value(10).present? && !self.closed?
    case 
        when (self.custom_field_value(10).to_date - Date.today).to_i < 0
        @issue.priority_id=(3)
        when(self.custom_field_value(10).to_date - Date.today).to_i  <= 7
        @issue.priority_id=(2)
        else 
        @issue.priority_id=(1)
    end
end

Have a nice day!

ashrafalzyoud commented 4 years ago

when issue closed not working i need it change issue.priority_id=(1)

AirTibu commented 4 years ago

Hi,

Could you please explain what does it mean: "when issue closed not working"?

The issue close should work, if the workflow allow to the user to close the issue.

ashrafalzyoud commented 4 years ago

i mean if the issue still active not closed issue.priority_id=(3) high when the issue closed ( state.id= 4 closed) must change @issue.priority_id=(1) low

.self.closed_on => date.today --> @issue.priority_id=(1) low

AirTibu commented 4 years ago

Hi,

Ok, I understand. You need this code:

if self.custom_field_value(10).present? && !self.closed?
    case 
        when (self.custom_field_value(10).to_date - Date.today).to_i < 0
        @issue.priority_id=(3)
        when(self.custom_field_value(10).to_date - Date.today).to_i  <= 7
        @issue.priority_id=(2)
        else 
        @issue.priority_id=(1)
    end
elsif self.closing?
         @issue.priority_id=(1)
end
ashrafalzyoud commented 4 years ago

thx for u brother another question plz how i can update all my issue becuase i need reopen issue by issue to effect formula are there formula to update all my issue in one command

ashrafalzyoud commented 4 years ago

im searching i found this formula

namespace :computed_custom_field do

def save_issue(issue, user) issue.init_journal(user) issue.children.each { |i| save_issue(i, user) } issue.reload issue.save! end

task :recalculate => :environment do if ENV['project_id'].present? projects = Project.where id: ENV['project_id'] else projects = Project.active end user = User.find ENV['user_id'] projects.each do |project| project.issues.where(parent_id: nil).each { |i| save_issue(i, user) } end end end

AirTibu commented 4 years ago

Hi,

Use bulk edit to update issues. Select all issues on issue list screen and right click, then Edit. Do not change anything, just click to submit button on bottom of page.

8BBC0015-E1D3-408C-B06D-E1DAC712352F

Approximately 300 issues can be modified at one time.

ashrafalzyoud commented 4 years ago

I have more than 5000 issues Can I use corntab in rake ???

ashrafalzyoud commented 4 years ago

See this site

https://github.com/annikoff/redmine_plugin_computed_custom_field/issues/22

But I don't know how use corntab I'm try

ashrafalzyoud commented 4 years ago

This task must be daily every morning because date now

AirTibu commented 4 years ago

Hi,

Maybe this plugin helps you:

Redmine Periodic Task: https://github.com/jperelli/Redmine-Periodic-Task

ashrafalzyoud commented 4 years ago

its not working this plugin see this link --> https://github.com/annikoff/redmine_plugin_computed_custom_field/issues/22 im try in crontab in ubuntu and this file in rakeFILE BUT ITS NOT WORKING ( 23 cd /home/redmine/4.1 && RAILS_ENV=production rake computed_custom_field:recalculate user_id=1)

AirTibu commented 4 years ago

Hi,

I can’t help you on this topic, because my company’s IT department handle this part of redmine, I don’t know the folder structure and plugin installation steps.

Are you sure, that the rake file in the right folder?

According to the description, it should be here: plugins/computed_custom_field/lib/tasks/recalculate.rake