Merge pull request #1031 from bookwyrm-social/search-dedup

Remove deduplication of external search results
This commit is contained in:
Mouse Reeve 2021-04-30 16:45:23 -07:00 committed by GitHub
commit 12b10fbd42
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -29,8 +29,6 @@ def search(query, min_confidence=0.1):
isbn = re.sub(r"[\W_]", "", query) isbn = re.sub(r"[\W_]", "", query)
maybe_isbn = len(isbn) in [10, 13] # ISBN10 or ISBN13 maybe_isbn = len(isbn) in [10, 13] # ISBN10 or ISBN13
dedup_slug = lambda r: "%s/%s/%s" % (r.title, r.author, r.year)
result_index = set()
for connector in get_connectors(): for connector in get_connectors():
result_set = None result_set = None
if maybe_isbn: if maybe_isbn:
@ -53,10 +51,6 @@ def search(query, min_confidence=0.1):
logger.exception(e) logger.exception(e)
continue continue
# if the search results look the same, ignore them
result_set = [r for r in result_set if dedup_slug(r) not in result_index]
# `|=` concats two sets. WE ARE GETTING FANCY HERE
result_index |= set(dedup_slug(r) for r in result_set)
results.append( results.append(
{ {
"connector": connector, "connector": connector,