Problem/Motivation

For the site I'm working on we need a usage-count filter in the media view. Unfortunately, the current solution has no easy way to distinguish between usage in a previous or the latest revision.

Steps to reproduce

Track usages of revisionable entities. Add a view with a filter on the sum of count or count/distinct of source_id. The usages of previous versions are also counted.

Proposed resolution

Track 'is latest revision' in the entity_usage table.

Remaining tasks

Review, tests, etc

User interface changes

None

API changes

\Drupal\entity_usage\EntityUsage::registerUsage method signature has changed.

Data model changes

New column in the entity_usage table 'source_is_latest_revision'

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

SpadXIII created an issue. See original summary.

spadxiii’s picture

Status: Active » Needs review
Anonymous’s picture

Patch applied but it still counts previous versions. If there are 4 revisions, it shows 1 usage as like 4.

theloneliestmonk made their first commit to this issue’s fork.

dmundra’s picture

Thank you @theloneliestmonk for rebasing. I think it would be also good to fix the errors in the merge request.

alexpott’s picture

I'm not sure I see how this works. As you add new revisions to a node won't all the entries into the entity usage table be marked as the latest revision?