Recalculating computed field on deleting logged time
dpalic opened this issue · 7 comments
the calculated value is sadly not getting updated if I delete any logged time.
My user expectation would be to get also update the calculated field on any change of related data of a issue.
(reposting, since could not reopen #8)
You could write some rake-task that will be re-save issues, and you could run it by cron.
afaik it was fixed in #8 ?
not getting it, now a workaround? Especially it would be a high load on a big redmine setup to rerun the trigger on all workitem?!?
if the workaround, how should the rake task look like? Would also expect it to have it in the user documentation, if this is the recommended way.
also found that on time log update the calculated field is also not getting updated
also on some seldom cases the recalculation is not done on a new time log, could not determine in which cases
Since version 1.0 recalculation of association was deleted. The code has been rewritten from scratch.
No backward compatibility with older versions.
Check #22
okay great will give it a try! Many thanks
One suggestion:
could you add the given script to the project repo, so all users can immediately use it?
Also could you reference this restrictions to the README.md so it is clear for all new users?
found more issues with the script:
the script needs to know the projects in advance. Since the calculated field (in my case) is the calculation of the remaining work time (spent / done - spent) this field is independent to any project and so I also have an issue to name all projects (and also any unknown future projects) with the rake task
so wondering if it would not be a better solution to have a similar integration like it was implemented with #8?
E.g. know from other issue trackers, that you can register to a save/update event of a issue. Not sure if redmine has such a approach (I am not a ruby/rake developer)? This would make the separation into an external running script obsolete (from my point of view not optimal in terms of software/system design)
after researching found your both commits
2a1ed3a and eb2082f from my perspective looks well. Why was this integrated support removed?
Thank you for your interest.
could you add the given script to the project repo, so all users can immediately use it?
No, this repo only for plugin's code. See an answer below.
Also could you reference this restrictions to the README.md so it is clear for all new users?
I think wiki with FAQ is a better solution instead of README. If I found enough time to write some documentation I will do it.
the script needs to know the projects in advance...
You could rewrite it for your purposes or run without project_id
parameter.
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
Issue.where(parent_id: nil).each { |i| save_issue(i, user) }
end
end
so wondering if it would not be a better...
The only purpose of this plugin is providing an ability to calculate user's formulas when an issue is saving. From my point of view, another functionality is unnecessary.
regarding your point of view, can understand this, sadly a change on any related object on the issue is also a save of the issue (in our terms)
so if we contribute this feature as a pull request, would you ignore it,
or would you rather integrate it?
I will ignore it. You'd better fork this repository and modify it for your needs.