Skip to content

Commit

Permalink
Fix all shards have failed on filter deletion
Browse files Browse the repository at this point in the history
Signed-off-by: BOUHOURS Antoine <[email protected]>
  • Loading branch information
antoinebhs committed Dec 17, 2024
1 parent 1da3840 commit af51f38
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ public void addAllTombstonedEquipmentInfos(@NonNull final List<TombstonedEquipme
}

public void deleteEquipmentInfosList(@NonNull List<String> equipmentIds, @NonNull UUID networkUuid, @NonNull String variantId) {
equipmentInfosRepository.deleteByIdInAndNetworkUuidAndVariantId(equipmentIds, networkUuid, variantId);
Lists.partition(equipmentIds, partitionSize)
.parallelStream()
.forEach(equipmentIdsSubList -> equipmentInfosRepository.deleteByIdInAndNetworkUuidAndVariantId(equipmentIdsSubList, networkUuid, variantId));
}

public void deleteVariants(@NonNull UUID networkUuid, List<String> variantIds) {
Expand Down Expand Up @@ -88,8 +90,8 @@ public void cloneVariantModifications(@NonNull UUID networkUuid, @NonNull String
);
}

public List<EquipmentInfos> findEquipmentInfosList(List<String> equipmentIds, UUID networkUuid, String variantId) {
return equipmentInfosRepository.findByIdInAndNetworkUuidAndVariantId(equipmentIds, networkUuid, variantId);
public List<EquipmentInfos> findEquipmentInfosList(UUID networkUuid, String variantId) {
return equipmentInfosRepository.findAllByNetworkUuidAndVariantId(networkUuid, variantId);
}

public void deleteAll() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,16 +245,15 @@ private static EquipmentInfos toEquipmentInfos(Identifiable<?> identifiable, UUI

private void flushEquipmentInfos() {
String variantId = network.getVariantManager().getWorkingVariantId();
Set<String> presentEquipmentDeletionsIds = equipmentInfosService.findEquipmentInfosList(
deletedEquipments.stream().map(EquipmentInfosToDelete::id).toList(),
Set<String> existingEquipmentIds = equipmentInfosService.findEquipmentInfosList(
networkUuid,
variantId
).stream().map(EquipmentInfos::getId).collect(Collectors.toSet());

List<String> equipmentDeletionsIds = new ArrayList<>();
List<TombstonedEquipmentInfos> tombstonedEquipmentInfos = new ArrayList<>();
deletedEquipments.forEach(deletedEquipment -> {
if (presentEquipmentDeletionsIds.contains(deletedEquipment.id())) {
if (existingEquipmentIds.contains(deletedEquipment.id())) {
equipmentDeletionsIds.add(deletedEquipment.id());
}
// add only allowed equipments types to be indexed to tombstonedEquipmentInfos
Expand Down

0 comments on commit af51f38

Please sign in to comment.