Skip to content

Commit

Permalink
sort categories by size before applying modifications
Browse files Browse the repository at this point in the history
  • Loading branch information
cbellone committed Mar 19, 2024
1 parent bfa5b85 commit eb32d73
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import alfio.model.group.Group;
import alfio.model.modification.EventModification;
import alfio.model.modification.LinkedGroupModification;
import alfio.model.modification.TicketCategoryModification;
import alfio.model.result.ErrorCode;
import alfio.model.result.Result;
import alfio.model.result.ValidationResult;
Expand Down Expand Up @@ -255,7 +256,7 @@ private Optional<Event> updateEvent(String slug, EventCreationRequest request, P
private void handleCategoriesUpdate(Principal user, EventModification em, EventWithAdditionalInfo original, Event event) {
if (em.getTicketCategories() != null && !em.getTicketCategories().isEmpty()) {
var existingCategories = original.getTicketCategories();
em.getTicketCategories().forEach(c -> {
em.getTicketCategories().stream().sorted(Comparator.comparing(TicketCategoryModification::getMaxTickets)).forEach(c -> {
var existingCategory = findExistingCategory(existingCategories, c.getName(), c.getId());
if (existingCategory.isPresent()) {
eventManager.updateCategory(existingCategory.get().getId(), event.getId(), c, user.getName());
Expand Down

0 comments on commit eb32d73

Please sign in to comment.