annikoff/redmine_plugin_computed_custom_field

How to get date of change status event?

Closed this issue · 4 comments

Hello,
I need to compute difference between dates.
Start date is field cfs[21].
End date is when issue status has changed (to specific status) or now if it hasnt changed.

My current code looks like that:
(Date.today - cfs[21]).to_i if cfs[21].present?

With this I can compute number of days between field cfs[21] and now.

Depending on status, sometimes I want to compute 1* or 2*.
1* - number of days between field cfs[21] and now.
2* - number of days between field cfs[21] and date of status change (when status of issue has changed to specific status)

Pseudocode

if (status != SPECIFIC_STATUS) {
  numberOfDays = Now() - cfs[21]
} else {
 numberOfDays = dateOfStatusChanged - cfs[21]
}

Hi.

journals.reverse.find { |j| j.details.find { |d| d.prop_key == 'status_id' && d.value.to_i == SPECIFIC_STATUS } }.try(:created_on).try(:to_date)

Good afternoon @annikoff , I am trying to calculate something similar to the mentioned, without success at the moment.
I need to get the number of years since the issue is in the current state.

I am trying in this way:

mayor = 0
if self.prop_key == 'status_id'
mayor = ((((Date.today - self.created_on) .to_i) .to_f / 365.15)). round (2)
mayor
end

getting by answer:

Formula undefined method `prop_key 'for # <Issue: 0x007fa5df5a8ac0>

Thank you very much

Hi. An issue has no prop_key field, every issue has many journals, every journal has many details and detail has prop_key field.

good morning @annikoff , how do you think I could solve what I need?
It should be able to identify the last status of each issue and calculate the time it takes in it.

I thank you for your collaboration.

regards