Patch #23954

Shows the date of the last activity on Projects administration.

Added by Frederico Camara almost 2 years ago. Updated 4 months ago.

Status:NewStart date:
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:Administration
Target version:Candidate for next major release

Description

On Administration > Projects, it shows the date of the last activity on each project. Helps the admin to decide when to close or archive stale projects.

last_activity.patch Magnifier (2.58 KB) Frederico Camara, 2016-09-28 22:00

screenshot-23954.png (42.3 KB) Go MAEDA, 2016-12-25 13:44

last_activity-1.patch Magnifier (2.63 KB) Frederico Camara, 2017-01-02 14:11

last_activity-2.r3.4.patch Magnifier - Performance patch for Redmine 3.4 (4.34 KB) Frederico Camara, 2018-03-08 18:53

last_activity-2.r3.3.patch Magnifier - Performance patch for Redmine <= 3.3 (4.34 KB) Frederico Camara, 2018-03-08 18:53

last_activity-3.r3.3.patch Magnifier - Performance patch for Redmine <= 3.3 (4.95 KB) Frederico Camara, 2018-03-09 22:09

last_activity-3.r3.4.patch Magnifier - Performance patch for Redmine 3.4 (5.03 KB) Frederico Camara, 2018-03-09 22:09


Related issues

Related to Redmine - Patch #13696: Projects admin, show issues count New

History

#1 Updated by Go MAEDA over 1 year ago

This is a screenshot of the feature.

But it should be considered that processing when event variable is nil in the following code. It causes undefined method `[]' for nil:NilClass error at the next line.

  def last_activity(project)
    event = Redmine::Activity::Fetcher.new(User.current, :project => project).events(nil, nil, :limit => 1)[0]
    byebug
    event[:updated_on].nil? ? event[:created_on] : event[:updated_on]
  end

#2 Updated by Yuuki NARA over 1 year ago

+1

#3 Updated by Frederico Camara over 1 year ago

Go Maeda,

Thank you for your reply. I had already patched production (https://github.com/fredsdc/redmine/tree/3.2-patched), and I forgot I had posted the patch to Redmine.org. Fixed it again today to call last_activity function only once.

It now returns the project creation date if there is no activity in the project.

#4 Updated by Go MAEDA over 1 year ago

  • Target version set to Candidate for next major release

Thank you for updating the patch. It works fine, looks good to me.

#5 Updated by Go MAEDA over 1 year ago

  • Related to Patch #13696: Projects admin, show issues count added

#6 Updated by Go MAEDA over 1 year ago

  • Target version changed from Candidate for next major release to 3.4.0

Although Jean-Phillipe Lang wrote on #13696#note-7 as follows, last activity is very useful to maintenance projects.

We'll add this as an optional column when the project list will be made configurable (like the issue list).

In my opinion, "Last activity" is far more useful information than "Created".
Could this be a part of 3.4.0?

#7 Updated by Robert Schneider over 1 year ago

Go MAEDA wrote:

In my opinion, "Last activity" is far more useful information than "Created".

That's true!

+1

#8 Updated by Jean-Philippe Lang over 1 year ago

  • Target version changed from 3.4.0 to Candidate for next major release

Go MAEDA wrote:

In my opinion, "Last activity" is far more useful information than "Created".

I'm not saying that this information is not usefull. It generates dozens of SQL queries and can make the project list really slow. We'll make this information available once the project list can be configured, but we can't add it by default now.

#9 Updated by Frederico Camara over 1 year ago

Jean-Philippe Lang wrote:

I'm not saying that this information is not usefull. It generates dozens of SQL queries and can make the project list really slow. We'll make this information available once the project list can be configured, but we can't add it by default now.

My thoughts exactly. I got it in production here and if you have dozens of projects, it generates lots and lots of queries. I kept it because it is just so useful, but with 400 projects and near 2000 issues, opening the admin projects page takes near 22 seconds.

I'm studying how to better query the database. Redmine::Activity::Fetcher only uses projects as filters. I would need to construct a table with each project id and its last activity using just a few SQL queries.

#10 Updated by Frederico Camara 4 months ago

I have a new patch. I added a new option to the fetcher library, if set, the result is a hash { project_id -> last_activity }, that I use in the view.

Summarizing I reduced the queries to one per event type, which takes now a fraction of a second to complete.

#11 Updated by Frederico Camara 4 months ago

I fixed a bug, and moved some code from the helpers to the controllers. I also had an idea how to always show some activity as Feature #3099.

Also available in: Atom PDF