Add case-insensitive name deduplication (cat = Cat = CAT)
Browse files- handler.py +6 -5
handler.py
CHANGED
|
@@ -154,19 +154,20 @@ class EndpointHandler:
|
|
| 154 |
with self._lock:
|
| 155 |
# Get ALL existing IDs and names from current state
|
| 156 |
known_ids = set(getattr(self, "class_ids", []))
|
| 157 |
-
|
|
|
|
| 158 |
|
| 159 |
-
# Filter items, checking against both ID and name
|
| 160 |
batch = []
|
| 161 |
for it in new_items:
|
| 162 |
item_id = int(it.get("id"))
|
| 163 |
item_name = it.get("name")
|
| 164 |
|
| 165 |
-
# Skip if either ID or name already exists
|
| 166 |
if item_id in known_ids:
|
| 167 |
continue # Skip duplicate ID
|
| 168 |
-
elif item_name in
|
| 169 |
-
continue # Skip duplicate name
|
| 170 |
else:
|
| 171 |
batch.append(it)
|
| 172 |
|
|
|
|
| 154 |
with self._lock:
|
| 155 |
# Get ALL existing IDs and names from current state
|
| 156 |
known_ids = set(getattr(self, "class_ids", []))
|
| 157 |
+
# Create lowercase set for case-insensitive comparison
|
| 158 |
+
known_names_lower = set(name.lower() for name in getattr(self, "class_names", []))
|
| 159 |
|
| 160 |
+
# Filter items, checking against both ID and name (case-insensitive)
|
| 161 |
batch = []
|
| 162 |
for it in new_items:
|
| 163 |
item_id = int(it.get("id"))
|
| 164 |
item_name = it.get("name")
|
| 165 |
|
| 166 |
+
# Skip if either ID or name already exists (case-insensitive for names)
|
| 167 |
if item_id in known_ids:
|
| 168 |
continue # Skip duplicate ID
|
| 169 |
+
elif item_name.lower() in known_names_lower:
|
| 170 |
+
continue # Skip duplicate name (case-insensitive)
|
| 171 |
else:
|
| 172 |
batch.append(it)
|
| 173 |
|