2

I have investigated a number of solutions that came close to my requirements, but not one that actually solves this, I think very common, use case:

Often after using feeds, there are duplicate entities created with the same title. Apart from the methods to prevent this from happening, I want to find a solution to list the most recently created entities of which the title already is in use.

When the most recent duplicates are listed, I want to bulk-delete them using views bulk operations.

My approach is as follows:

  1. Create a view that lists titles of all entities of a certain bundle.
  2. Turn on aggregation
  3. Add the entity ID as field, with aggregation 'Count'
  4. Add a filter: entity ID with aggregation 'Count' is 'more than 1'

The result is a list of entity titles with a column of the count of entities having that title.

Question 1:

So far so good, but I need to see the latest entities listed with an already existing title. How to make that happen?

Question 2:

I need to bulk-delete these most recent duplicates, preferably using Views Bulk Operations. However, when I add VBO(for entities) to the view, this results in an empty output. Probably because the aggregated list shows titles and not entities. This is caused by question 1 not being resolved.

EDIT: I came up with the idea to use this view of duplicate titles, as a filter for another view that should show the latest entities having those titles. So my 3rd question would be:

QUESTION 3: How to create a view that uses the aggregated view mentioned above as its filter, to show the entities having those titles.

1 Answer 1

2

I solved this using the modules

  • Flags
  • Rules
  • Views Rules
  • Rules links

with the following method:

  1. Added a flag 'in bucket' connected to the entity
  2. Created A views Rules display listing all entities
  3. Created a rules link, which includes a rule with an action 'Views loop' that performs an action on each entity in the views Rules display. The action performed is a rules component that again uses a views loop checking if a duplicate title is present. So for every views list item, all views list items are compared.
  4. If a duplciate title is found, the entity is flagged with the 'in bucket' flag. The Rules link has as a last action the redirection to the view that shows all entities in the bucket.
  5. To make this more reliable, add as first action of the rules link, a loop to remove all entities from the bucket (remove all flags).

In this way, with one click all entities are checked on duplicate titles, and the found duplciates are shown.

However, this is not the most efficient and performant way for large lists. For example when having 2000 entities, rules will need to process 2K x 2K = 4M times the comparison. I had to limit my list to 350 items in order to have processing time of 5 minutes. I tried to implement batch processing of the views loops, but did not succeed yet.

A more efficient way would probably be to use the view as mentioned in the question, and use that list of titles as a filter for another view which should show the most recent entities having one of this titles. I haven't figured out how to do this yet.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.