New command to merge entities

Bastien Abadie
2022-07-12T08:37:40Z

Refs https://gitlab.com/arkindex/requests/-/issues/716

We need a new django command named merge_entities that simply takes a corpus ID as input and then merges all similar entities.

This means all entities with the same type+name+value would be merged into a single one.

I suggest:

1. making a query to list all duplicates entities (maybe easier with a raw sql and a group by, but it should be possible with django aggregation)

2. listing all cases, taking the first available one as the new "source"

3. updating all other references to that one

4. removing all deprecated entities