プロジェクト

全般

プロフィール

Vote #80517

未完了

Rake taks works on redmine 3.4 but does not work on 4 while for Redmine 4 it works in console

Admin Redmine さんが約4年前に追加. 約4年前に更新.

ステータス:
New
優先度:
通常
担当者:
-
カテゴリ:
Custom fields_14
対象バージョン:
-
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
14
version_id:
0
issue_org_id:
32537
author_id:
5107
assigned_to_id:
0
comments:
2
status_id:
1
tracker_id:
1
plus1:
0
affected_version:
closed_on:
affected_version_id:
151
ステータス-->[New]

説明

I have described problem here:

https://stackoverflow.com/questions/59104015/saving-issue-custom-field-values-via-rake-task-in-redmine?noredirect=1#comment104442404_59104015

So, same code works in console on Redmine 4, and on Redmine 3.4 it works well in both console and as rake task.

On Redmine 4, as rake task, it says "saved" but no actual database change occured.


journals

Eventually I was able to make the following code work with Redmine 4

<pre>
namespace :redmine do
namespace :myplugin do
desc 'Updates custom field for idle tickets.'
task :update_idle => :environment do
Issue.open.each do |issue|
begin
days = DateTime.now.to_time - DateTime.parse(issue.updated_on.to_s).to_time
days = days/86400
if days > 0
issue.custom_values.each do |x|
if x.custom_field_id == 19
x.value = days.ceil
x.save
end
end
issue.save
true
end
end
end
end
end
end

</pre>
But I still think above described behavior is bug...
--------------------------------------------------------------------------------
Could you try again after changing all @save@ method to @save!@ method?

@save!@ thorows an exception when it fails. Probably it is useful to troubleshoot this issue.
--------------------------------------------------------------------------------

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0