@@ -0,0 +1,1838 @@
+import com.mongodb.Block;%0Aimport com.mongodb.client.MongoCollection;%0Aimport com.mongodb.client.MongoDatabase;%0Aimport fr.inria.spirals.repairnator.serializer.mongodb.MongoConnection;%0Aimport org.bson.Document;%0Aimport org.bson.types.ObjectId;%0A%0Aimport java.util.HashSet;%0Aimport java.util.Set;%0A%0Aimport static com.mongodb.client.model.Filters.eq;%0Aimport static com.mongodb.client.model.Sorts.descending;%0Aimport static com.mongodb.client.model.Sorts.orderBy;%0A%0A/**%0A * Created by urli on 10/10/2017.%0A */%0Apublic class RemoveDuplicatedBuildsId %7B%0A    static int counterDeleted = 0;%0A    static int counterKept = 0;%0A%0A    public static void main(String%5B%5D args) %7B%0A        Set%3CInteger%3E buildIds = new HashSet%3C%3E();%0A%0A        String dbCollectionUrl = args%5B0%5D;%0A        String dbName = args%5B1%5D;%0A        String collectionName = args%5B2%5D;%0A%0A        MongoConnection mongoConnection = new MongoConnection(dbCollectionUrl, dbName);%0A        MongoDatabase database = mongoConnection.getMongoDatabase();%0A        MongoCollection collection = database.getCollection(collectionName);%0A%0A%0A        Block%3CDocument%3E block = new Block%3CDocument%3E()%7B%0A%0A            @Override%0A            public void apply(Document document) %7B%0A                int buildId = document.getInteger(%22buildId%22);%0A                ObjectId id = document.getObjectId(%22_id%22);%0A%0A                if (buildIds.contains(buildId)) %7B%0A                    collection.deleteOne(eq(%22_id%22, id));%0A                    counterDeleted++;%0A                    return;%0A                %7D else %7B%0A                    buildIds.add(buildId);%0A                    counterKept++;%0A                %7D%0A            %7D%0A        %7D;%0A        collection.find().sort(orderBy(descending(%22buildReproductionDate%22))).forEach(%0A                block%0A        );%0A%0A        System.out.println(counterDeleted+%22 entries deleted and %22+counterKept+%22 kept.%22);%0A    %7D%0A%7D%0A

Add another sandbox script