Allow searching for members by email

This commit is contained in:
Tanner Collin 2020-03-29 02:42:11 +00:00
parent 3a9fd875b2
commit a3db260e08
2 changed files with 10 additions and 3 deletions

View File

@ -143,7 +143,14 @@ def gen_search_strings():
string = '{} {}'.format(
m.preferred_name,
m.last_name,
).lower()
)
if m.old_email:
string += ' ' + m.old_email
if m.user:
string += ' ' + m.user.email
string = string.lower()
search_strings[string] = m.id
cache.set('search_strings', search_strings)

View File

@ -69,8 +69,8 @@ class SearchViewSet(Base, Retrieve):
# then get exact substring matches
results += [x for x in choices if search in x]
if len(results) == 0 and len(search) >= 3:
# then get fuzzy matches
if len(results) == 0 and len(search) >= 3 and '@' not in search:
# then get fuzzy matches, but not for emails
fuzzy_results = process.extract(search, choices, limit=NUM_SEARCH_RESULTS, scorer=fuzz.token_set_ratio)
results += [x[0] for x in fuzzy_results]