Skip to content
This repository was archived by the owner on Aug 1, 2025. It is now read-only.

Commit 76665ab

Browse files
committed
[BI-2304] - changes based on review
1 parent 06b8cac commit 76665ab

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/main/java/org/brapi/test/BrAPITestServer/service/core/ListService.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -237,11 +237,14 @@ private void updateEntity(ListEntity entity, @Valid ListNewRequest list) throws
237237
List<ListItemEntity> items = new ArrayList<>();
238238
ListIterator<String> iter = list.getData().listIterator();
239239
while (iter.hasNext()) {
240-
ListItemEntity itemEntity = new ListItemEntity();
241-
itemEntity.setPosition(iter.nextIndex());
242-
itemEntity.setItem(iter.next());
243-
itemEntity.setList(entity);
244-
items.add(itemEntity);
240+
String item = iter.next();
241+
if (item != null) {
242+
ListItemEntity itemEntity = new ListItemEntity();
243+
itemEntity.setPosition(iter.nextIndex());
244+
itemEntity.setItem(item);
245+
itemEntity.setList(entity);
246+
items.add(itemEntity);
247+
}
245248
}
246249
entity.setData(items);
247250
} else {

src/main/resources/db/migration/V002__add_list_position.sql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,7 @@
33
-- Add position to list_item.
44
ALTER TABLE list_item
55
ADD COLUMN position INT NOT NULL DEFAULT 0;
6+
-- Add an index on the position column
7+
CREATE INDEX idx_list_item_position ON list_item(position);
8+
-- Add a composite index on list_id and position for better performance when querying items within a specific list
9+
CREATE INDEX idx_list_item_list_position ON list_item(list_id, position);

0 commit comments

Comments
 (0)