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