mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-01-12 21:44:21 -06:00
Fix fuzzy matching lists of object / names
This commit is contained in:
@@ -71,9 +71,9 @@ def _match_names_to_queryset(names: list[str], queryset, attr: str):
|
||||
# First try exact match
|
||||
if target in object_names:
|
||||
index = object_names.index(target)
|
||||
results.append(objects[index])
|
||||
# Remove the matched name from the list to avoid fuzzy matching later
|
||||
object_names.remove(target)
|
||||
matched = objects.pop(index)
|
||||
object_names.pop(index) # keep object list aligned after removal
|
||||
results.append(matched)
|
||||
continue
|
||||
|
||||
# Fuzzy match fallback
|
||||
@@ -85,7 +85,9 @@ def _match_names_to_queryset(names: list[str], queryset, attr: str):
|
||||
)
|
||||
if matches:
|
||||
index = object_names.index(matches[0])
|
||||
results.append(objects[index])
|
||||
matched = objects.pop(index)
|
||||
object_names.pop(index)
|
||||
results.append(matched)
|
||||
else:
|
||||
pass
|
||||
return results
|
||||
|
||||
Reference in New Issue
Block a user