Feature #824

Add "closed_on" issue field (storing time of last closing) & add it as a column and filter on the issue list.

Added by Rocco Stanzione over 9 years ago. Updated over 3 years ago.

Status:ClosedStart date:2008-03-10
Priority:NormalDue date:
Assignee:Jean-Philippe Lang% Done:

0%

Category:Issues
Target version:2.3.0
Resolution:Fixed

Description

In our regular planning sessions we like to see what issues were closed in the last, say, week. The closest thing we have is closed? and updated_on, which isn't always accurate (sometimes closed issues get modified). It would be nice to have a closed_on field on the issues table that gets updated when the status changes from not-closed to closed.


Related issues

Related to Redmine - Defect #20210: Issue closed_on date is not reset after issue is reopened Closed
Duplicated by Redmine - Feature #13014: Record issue closing date Closed
Duplicated by Redmine - Feature #2225: Provide a Date Closed element for queries Closed 2008-11-24
Blocks Redmine - Feature #4730: Add Closed Date to Issue Filter Closed 2010-02-03
Blocks Redmine - Feature #6795: View issue close date on the gantt view New 2010-11-02
Blocks Redmine - Feature #5705: Display Issue Closed Date on Calendar View New 2010-06-17

Associated revisions

Revision 11402
Added by Jean-Philippe Lang almost 5 years ago

Adds closed_on column that stores the time of the last closing (#824).

The value is preserved when reopening the issue.

Revision 11403
Added by Jean-Philippe Lang almost 5 years ago

Makes closed_on available as column and filter on the issue list (#824).

Revision 11404
Added by Jean-Philippe Lang almost 5 years ago

Adds field_closed_on to locales (#824).

Revision 11411
Added by Jean-Philippe Lang almost 5 years ago

Adds closed_on to issues API responses (#824).

History

#1 Updated by Rocco Stanzione over 9 years ago

I looked into implementing this, and it might have to get a little invasive. I was thinking instead of setting @issue_before_change in init_journal, do something like:

attr_reader :original_attributes
def after_find
  original_attributes = attributes
end

Then anywhere you need to, you can access the original_attributes hash to see what's being changed with this save. So in before_save, you could:

closed_at = Time.now if IssueStatus.find(original_attributes.status_id).is_closed? && !self.closed

Or to save some syntax you could clone the whole issue into an :original_issue attr_reader.

#2 Updated by Henrique Bastos over 9 years ago

What would happen if you reopen the issue?

#3 Updated by Robert Hailey about 6 years ago

Henrique Bastos wrote:

What would happen if you reopen the issue?

The answer to this question seems obvious, but I suppose it might as well be stated....

In that case it would maintain it's previous closed_on attribute, which would be updated again later if/when it is re-closed. The fact that the issue was reopened does not change the fact that it was once closed.

#4 Updated by Rocco Stanzione about 6 years ago

I'm not sure I agree. If I search for issues closed in the last 7 days, I don't think I should need a separate filter to constrain the search to issues that are currently closed, and I don't think the data in closed_on is useful for issues that aren't closed.

#5 Updated by Mischa The Evil almost 6 years ago

As mentioned in #4730, this feature is provided by the Issue Closed Date plugin

#6 Updated by Daniel Felix about 5 years ago

+1 for core implementation.

#7 Updated by Joshua DeClercq almost 5 years ago

Two things to add here:

  1. I agree with leaving a closed field populated even after reopening. Requiring an extra filter is added robustness, not tedium, and allows you to rapidly filter issues that were previously closed regardless of their current status. Everything gained by keeping this value recorded outweighs this one extra act of filtering for one particular use case.
  2. I highly recommend the Custom Workflows plugin to achieve this in the meantime. It's much more versatile than a dedicated plugin for this purpose, and is much more likely to maintained (already the Issue Closed Date plugin is far out of date). If using this plugin, here's my junky contribution to the topic:
if @issue.status_id_changed?
  if @issue.closing?
    @issue.custom_field_values = {'1' => Time.now.strftime("%Y-%m-%d")}
    # Where 1 is the ID of a 'closed on' date custom field
  end
end

Create a custom field, date type, for the closing date value. Make note of its ID. Create a new custom workflow with the above in the before-saving box, replacing the ID with the one you'll be using. Enable the field and the script on whatever trackers and projects you want this recorded for.

I advise this over a single-use plugin because this one plugin will give you this plus everything else it can do, and that means more customization with fewer plugin dependencies in your Redmine build.

#8 Updated by Filou Centrinov almost 5 years ago

Henrique Bastos wrote:

What would happen if you reopen the issue?

Always show the date of last closed status. If never has been closed before, don't show any date.
+1

#9 Updated by Jean-Philippe Lang almost 5 years ago

  • Status changed from New to Closed
  • Assignee set to Jean-Philippe Lang
  • Target version set to 2.3.0
  • Resolution set to Fixed

Feature added.

Filou Centrinov wrote:

Always show the date of last closed status. If never has been closed before, don't show any date.

This is how it was implemented as most people requested this behaviour. The closed_on column is preserved when the issue is reopened.

#10 Updated by Mischa The Evil almost 5 years ago

  • Subject changed from "closed_on" issues field to Add "closed_on" issue field (storing time of last closing) & add it as a column and filter on the issue list.

For roadmap/changelog: extending subject to better circumscribe the new feature.

#11 Updated by Bruno Spyckerelle over 4 years ago

It would be very usefull to be able to change the closed_on date as we can change the start and due dates (for example if someone forgot to close the issue and we want to record the real closed_on date).

#12 Updated by Mischa The Evil over 4 years ago

Bruno Spyckerelle wrote:

It would be very usefull to be able to change the closed_on date as we can change the start and due dates (for example if someone forgot to close the issue and we want to record the real closed_on date).

Please open a new feature request for this. This issue is completed and released.

#13 Updated by Toshi MARUYAMA over 3 years ago

Mischa The Evil wrote:

Bruno Spyckerelle wrote:

It would be very usefull to be able to change the closed_on date as we can change the start and due dates (for example if someone forgot to close the issue and we want to record the real closed_on date).

Please open a new feature request for this. This issue is completed and released.

FTR: There is #8002 already.

#14 Updated by Jean-Philippe Lang over 2 years ago

  • Related to Defect #20210: Issue closed_on date is not reset after issue is reopened added

Also available in: Atom PDF