Skip to content

armgit / mwmbl

Public Imported from GitHub
0

An open source, non-profit web search engine

Remove curation from results from other terms

Daoud Clarke3f41588be4d3
diff --git a/devdata/index-v2.tinysearch b/devdata/index-v2.tinysearch
index 140157a..c7093cf 100644
Binary files a/devdata/index-v2.tinysearch and b/devdata/index-v2.tinysearch differ
diff --git a/mwmbl/templates/home.html b/mwmbl/templates/home.html
index 8318424..49009b2 100644
--- a/mwmbl/templates/home.html
+++ b/mwmbl/templates/home.html
@@ -21,7 +21,7 @@
hx-post="/app/revert-current/"
hx-target=".main"
hx-vals='{"curation_id": {{ curation.id }}}'
- hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'>↺ Revert {{ curation.num_changes }} changes</button>
+ hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'>↺ Revert {{ curation.num_changes }} change{{ curation.num_changes|pluralize:"s" }}</button>
{% else %}
<button class="disabled-button" id="revert-button">↺ Revert</button>
{% endif %}
diff --git a/mwmbl/tinysearchengine/rank.py b/mwmbl/tinysearchengine/rank.py
index 32ce088..9586ae4 100644
--- a/mwmbl/tinysearchengine/rank.py
+++ b/mwmbl/tinysearchengine/rank.py
@@ -129,6 +129,16 @@ def fix_document_state(result: Document):
return fixed_document
+def remove_curate_state(state: DocumentState):
+ if state == DocumentState.ORGANIC_APPROVED:
+ return None
+ if state == DocumentState.FROM_USER_APPROVED:
+ return DocumentState.FROM_USER
+ if state == DocumentState.FROM_GOOGLE_APPROVED:
+ return DocumentState.FROM_GOOGLE
+ return state
+
+
class Ranker:
def __init__(self, tiny_index: TinyIndex, completer: Completer):
self.tiny_index = tiny_index
@@ -194,7 +204,16 @@ class Ranker:
if term == curation_term:
items = curation_items
else:
- items = self.tiny_index.retrieve(term)
+ items_wrong_state = self.tiny_index.retrieve(term)
+ # If this is not a curation term, it is not curated for the current term
+ items = [Document(result.title,
+ result.url,
+ result.extract,
+ result.score,
+ result.term,
+ remove_curate_state(result.state))
+ for result in items_wrong_state]
+
if items is not None:
pages += items