Come for the code, stay for the community

List projects by last updated task

Updating a project task should bump it to the top of the list.

The problem is that I can't list projects and sort by date changed on tasks without adding all the tasks to the view.

The distinct option is not working.

Aggregation is behaving strangely.

Grouping isn't working either.

Issue: Views relationships with multi-valued entity reference fields invalidate Distinct query option

TODO: Take a look at how comment tracks last comment time.


Comment maintains a database table to track the last comment time on entities.

This data can be used in views, avoiding the issues with aggregation/grouping/distinct.

A similar technique can be set up with a Last updated field and ECA.

Add a Last updated timestamp field to the parent entity.

Create an ECA that responds to Task insert/update. Load the corresponding project and set the Last updated value to the current time.


Alternatively, it would be possible to use Corresponding Entity References.

Add a reference field on the Project to Tasks, and set up CER to sync the references.

When a task is added, the Project gets updated, setting it's changed time, which can be used to sort.

I didn't do it this way to keep the Project's changed property separate from the Last updated task value.

Modules
Task type

Subtasks