Fixed a missed update to the search functionality that now should use db_tagtype rather than the old and hackish category-prefix solution. Resolves #497.
This commit is contained in:
parent
87d621bcbc
commit
8046679980
2 changed files with 4 additions and 5 deletions
|
|
@ -1898,8 +1898,7 @@ class CmdFind(MuxCommand):
|
||||||
nresults = results.count()
|
nresults = results.count()
|
||||||
if not nresults:
|
if not nresults:
|
||||||
# no matches on the keys. Try aliases instead.
|
# no matches on the keys. Try aliases instead.
|
||||||
results = ObjectDB.objects.filter(db_tags__db_key__iexact=searchstring, db_tags__db_category__iexact="object_alias")
|
results = ObjectDB.objects.filter(db_tags__db_key__iexact=searchstring, db_tags__db_tagtype__iexact="alias")
|
||||||
#results = ObjectDB.db_aliases.filter(db_key=searchstring)
|
|
||||||
if "room" in switches:
|
if "room" in switches:
|
||||||
results = results.filter(db_location__isnull=True)
|
results = results.filter(db_location__isnull=True)
|
||||||
if "exit" in switches:
|
if "exit" in switches:
|
||||||
|
|
|
||||||
|
|
@ -199,6 +199,7 @@ class ObjectManager(TypedObjectManager):
|
||||||
# if candidates is an empty iterable there can be no matches
|
# if candidates is an empty iterable there can be no matches
|
||||||
# Exit early.
|
# Exit early.
|
||||||
return []
|
return []
|
||||||
|
|
||||||
# build query objects
|
# build query objects
|
||||||
candidates_id = [_GA(obj, "id") for obj in make_iter(candidates) if obj]
|
candidates_id = [_GA(obj, "id") for obj in make_iter(candidates) if obj]
|
||||||
cand_restriction = candidates != None and Q(pk__in=make_iter(candidates_id)) or Q()
|
cand_restriction = candidates != None and Q(pk__in=make_iter(candidates_id)) or Q()
|
||||||
|
|
@ -206,7 +207,7 @@ class ObjectManager(TypedObjectManager):
|
||||||
if exact:
|
if exact:
|
||||||
# exact match - do direct search
|
# exact match - do direct search
|
||||||
return self.filter(cand_restriction & type_restriction & (Q(db_key__iexact=ostring) |
|
return self.filter(cand_restriction & type_restriction & (Q(db_key__iexact=ostring) |
|
||||||
Q(db_tags__db_key__iexact=ostring) & Q(db_tags__db_category__iexact="objectalias"))).distinct()
|
Q(db_tags__db_key__iexact=ostring) & Q(db_tags__db_tagtype__iexact="alias"))).distinct()
|
||||||
elif candidates:
|
elif candidates:
|
||||||
# fuzzy with candidates
|
# fuzzy with candidates
|
||||||
key_candidates = self.filter(cand_restriction & type_restriction)
|
key_candidates = self.filter(cand_restriction & type_restriction)
|
||||||
|
|
@ -220,8 +221,7 @@ class ObjectManager(TypedObjectManager):
|
||||||
if index_matches:
|
if index_matches:
|
||||||
return [obj for ind, obj in enumerate(key_candidates) if ind in index_matches]
|
return [obj for ind, obj in enumerate(key_candidates) if ind in index_matches]
|
||||||
else:
|
else:
|
||||||
alias_candidates = self.filter(id__in=candidates_id, db_tags__db_category__iexact="objectalias")
|
alias_candidates = self.filter(id__in=candidates_id, db_tags__db_tagtype__iexact="alias")
|
||||||
#print alias_candidates
|
|
||||||
alias_strings = alias_candidates.values_list("db_key", flat=True)
|
alias_strings = alias_candidates.values_list("db_key", flat=True)
|
||||||
index_matches = string_partial_matching(alias_strings, ostring, ret_index=True)
|
index_matches = string_partial_matching(alias_strings, ostring, ret_index=True)
|
||||||
if index_matches:
|
if index_matches:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue