Project

General

Profile

Actions

Feature #23954

closed

Shows the date of the last activity on Projects administration

Added by Frederico Camara about 8 years ago. Updated about 2 months ago.

Status:
Closed
Priority:
Normal
Category:
Projects
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Fixed

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.


Files

last_activity.patch (2.58 KB) last_activity.patch Frederico Camara, 2016-09-28 22:00
screenshot-23954.png (42.3 KB) screenshot-23954.png Go MAEDA, 2016-12-25 13:44
last_activity-1.patch (2.63 KB) last_activity-1.patch Frederico Camara, 2017-01-02 14:11
last_activity-2.r3.4.patch (4.34 KB) last_activity-2.r3.4.patch Performance patch for Redmine 3.4 Frederico Camara, 2018-03-08 18:53
last_activity-2.r3.3.patch (4.34 KB) last_activity-2.r3.3.patch Performance patch for Redmine <= 3.3 Frederico Camara, 2018-03-08 18:53
last_activity-3.r3.3.patch (4.95 KB) last_activity-3.r3.3.patch Performance patch for Redmine <= 3.3 Frederico Camara, 2018-03-09 22:09
last_activity-3.r3.4.patch (5.03 KB) last_activity-3.r3.4.patch Performance patch for Redmine 3.4 Frederico Camara, 2018-03-09 22:09
23954-trunk-note11.png (113 KB) 23954-trunk-note11.png Yuuki NARA, 2019-09-21 06:01
0001-Adds-last-activity-column-to-projects-list.patch (10 KB) 0001-Adds-last-activity-column-to-projects-list.patch Marius BĂLTEANU, 2020-04-05 12:17

Related issues

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

Actions
Related to Redmine - Feature #29482: Query system for Projects pageClosedJean-Philippe Lang

Actions
Related to Redmine - Feature #805: Allow projects view to be sorted by activityNew2008-03-07

Actions
Related to Redmine - Feature #3099: Last activity time window.New2009-04-02

Actions
Related to Redmine - Feature #40706: Enhance "Last activity" column to link to project activity pageClosedMarius BĂLTEANU

Actions
Related to Redmine - Patch #41678: Fix lost backward compatibility about return type of ProjectQuery#results_scopeClosedMarius BĂLTEANU

Actions
Related to Redmine - Defect #41791: Projects endpoint returns list of all projectsClosedMarius BĂLTEANU

Actions
Actions #1

Updated by Go MAEDA almost 8 years 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
Actions #2

Updated by Yuuki NARA almost 8 years ago

+1

Actions #3

Updated by Frederico Camara almost 8 years 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.

Actions #4

Updated by Go MAEDA almost 8 years ago

  • Target version set to Candidate for next major release

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

Actions #5

Updated by Go MAEDA almost 8 years ago

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

Updated by Go MAEDA almost 8 years 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?

Actions #7

Updated by Robert Schneider almost 8 years ago

Go MAEDA wrote:

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

That's true!

+1

Actions #8

Updated by Jean-Philippe Lang almost 8 years 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.

Actions #9

Updated by Frederico Camara almost 8 years 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.

Actions #10

Updated by Frederico Camara almost 7 years 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.

Actions #11

Updated by Frederico Camara almost 7 years 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.

Actions #12

Updated by Marius BĂLTEANU over 6 years ago

Actions #13

Updated by Yuuki NARA over 5 years ago

It worked on Redmine trunk with the same changes. note-11

Attach a screen copy of my environment.
Last activity is not displayed for projects with 0 tickets.
However, as it can be seen from the Created column, I think that it is enough as it is.

Actions #14

Updated by Marius BĂLTEANU over 5 years ago

I think we should add this column on top of #29482.

Actions #15

Updated by Ryoji Takeuchi about 5 years ago

+1

Actions #16

Updated by Marius BĂLTEANU about 5 years ago

  • File 0001-Adds-last-activity-column-to-projects-list.patch added

Based on Frederico Camara work, I've created a patch that adds the "Last activity" column to the projects list.

Sorting by this column is not possible for now because I'm not sure how to implement it easily (the last activity date is calculated based on multiple tables). Any suggestion is welcome.

Actions #17

Updated by Marius BĂLTEANU about 5 years ago

  • File deleted (0001-Adds-last-activity-column-to-projects-list.patch)
Actions #18

Updated by Marius BĂLTEANU about 5 years ago

  • File 0001-Adds-last-activity-column-to-projects-list.patch added

Slightly improved the patch in order to avoid some unnecessary joins when counting the number of results.

Actions #19

Updated by Marius BĂLTEANU about 5 years ago

  • File deleted (0001-Adds-last-activity-column-to-projects-list.patch)
Actions #20

Updated by Marius BĂLTEANU about 5 years ago

  • File 0001-Adds-last-activity-column-to-projects-list.patch added
Actions #21

Updated by Marius BĂLTEANU about 5 years ago

  • Related to Feature #805: Allow projects view to be sorted by activity added
Actions #22

Updated by Marius BĂLTEANU almost 5 years ago

  • File deleted (0001-Adds-last-activity-column-to-projects-list.patch)
Actions #23

Updated by Marius BĂLTEANU almost 5 years ago

  • File 0001-Adds-last-activity-column-to-projects-list.patch added
  • Category changed from Administration to Projects
  • Assignee set to Jean-Philippe Lang
  • Target version changed from Candidate for next major release to 4.2.0

Updated the patch for current trunk.

@Jean-Philippe, I'm assigning to you in order to:
  • review the changes proposed by Frederico Camara to activity fetcher
  • check for any solution to enable projects sorting by last activity date
Actions #24

Updated by Toshi MARUYAMA over 4 years ago

Actions #25

Updated by Marius BĂLTEANU over 4 years ago

  • File deleted (0001-Adds-last-activity-column-to-projects-list.patch)
Actions #27

Updated by Marius BĂLTEANU over 3 years ago

  • Target version changed from 4.2.0 to 5.0.0
Actions #28

Updated by zumo de vidrio over 3 years ago

Can you please share the SQL query or API request in order to get the last activity date of every project ?

Actions #29

Updated by Frederico Camara over 3 years ago

zumo de vidrio wrote:

Can you please share the SQL query or API request in order to get the last activity date of every project ?

As a hash:

Redmine::Activity::Fetcher.new(User.current).events(nil, nil, :last_by_project => true).to_h

Actions #30

Updated by Marius BĂLTEANU almost 3 years ago

  • Target version changed from 5.0.0 to Candidate for next major release
Actions #31

Updated by Olivier Croquette 8 months ago

I am trying to identify inactive projects in an instance that I am administrating. This feature would be very useful, but unfortunately it is not available in the releases. I have two questions:

- From the comments, I understand that the current implementation is too slow when there are many projects. Would it be possible to save the last project activity date when it happens, instead of trying to compute it on-demand? Retrieving it would be very quick then.
- In the current release, is there any other way to get the information?

Actions #32

Updated by Frederico Camara 8 months ago

Olivier Croquette wrote in #note-31:

- From the comments, I understand that the current implementation is too slow when there are many projects. Would it be possible to save the last project activity date when it happens, instead of trying to compute it on-demand? Retrieving it would be very quick then.

My institution has 444 projects (active and archived in the database). When showing all projects, 500 projects per page, it takes less than 3 seconds to refresh the projects page that computes that information.

I don't think it's slow in the current implementation. My initial implementation (before comment #23954-10) was very slow.

- In the current release, is there any other way to get the information?

I can think of a few, using sql, rails console, the rest api, and the activities tab in each project. Not good alternatives.

Actions #33

Updated by Marius BĂLTEANU 8 months ago

  • Status changed from New to Resolved
  • Assignee changed from Jean-Philippe Lang to Marius BĂLTEANU
  • Target version changed from Candidate for next major release to 6.0.0

The last activity date is now available as a column in Project query, I just committed the patch.

Frederico Camara, did you find a way to make the column sortable? or should I take a look into this?

Actions #34

Updated by Marius BĂLTEANU 8 months ago

  • Tracker changed from Patch to Feature
  • Resolution set to Fixed
Actions #35

Updated by Frederico Camara 8 months ago

Marius BĂLTEANU wrote in #note-33:

The last activity date is now available as a column in Project query, I just committed the patch.

Frederico Camara, did you find a way to make the column sortable? or should I take a look into this?

Columns were not sortable in Admin > Projects in 4.x or 5.x. I'm yet to look into Redmine 6.0.

Actions #36

Updated by Go MAEDA 7 months ago

  • Subject changed from Shows the date of the last activity on Projects administration. to Shows the date of the last activity on Projects administration
Actions #37

Updated by Go MAEDA 7 months ago

  • Related to Feature #40706: Enhance "Last activity" column to link to project activity page added
Actions #38

Updated by Marius BĂLTEANU 7 months ago

The column now links to Project activity page, please see r22848 (#40706).

I'm keeping this open to conclude on the sort mechanism.

Actions #39

Updated by Marius BĂLTEANU about 2 months ago

  • Status changed from Resolved to Closed

I'm closing this without the option to sort by Last activity date, we will track this improvement in #805.

Actions #40

Updated by Go MAEDA about 2 months ago

  • Status changed from Closed to Reopened
Actions #41

Updated by Marius BĂLTEANU about 2 months ago

  • Related to Patch #41678: Fix lost backward compatibility about return type of ProjectQuery#results_scope added
Actions #42

Updated by Marius BĂLTEANU about 2 months ago

  • Status changed from Reopened to Closed
Actions #43

Updated by Holger Just about 1 month ago

  • Related to Defect #41791: Projects endpoint returns list of all projects added
Actions

Also available in: Atom PDF