Skip to content

Commit 66a55d9

Browse files
tillprochaskalinusha
authored andcommitted
Remove SLOT_TIMESTAMP, SLOT_IS_FEATURED constants for consistency
Missed these in 53a1099.
1 parent 0ffb4f4 commit 66a55d9

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

backend/howtheyvote/search.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,9 @@ class AccessType(enum.Enum):
4646
# sorting, custom scoring, aggregations, etc. it makes sense to store them as a value. Each
4747
# value is stored in a numbered slot.
4848
# See: https://getting-started-with-xapian.readthedocs.io/en/latest/concepts/indexing/values.html
49-
SLOT_TIMESTAMP = 0
50-
SLOT_IS_FEATURED = 1
51-
5249
FIELD_TO_SLOT_MAPPING = {
53-
"timestamp": SLOT_TIMESTAMP,
54-
"is_featured": SLOT_IS_FEATURED,
50+
"timestamp": 0,
51+
"is_featured": 1,
5552
}
5653

5754
# Some document fields are more important than others. The following factors are applied

backend/howtheyvote/store/index.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@
99
from ..helpers import chunks
1010
from ..models import BaseWithId, Vote
1111
from ..search import (
12-
SLOT_IS_FEATURED,
13-
SLOT_TIMESTAMP,
1412
AccessType,
1513
boolean_term,
1614
field_to_prefix,
15+
field_to_slot,
1716
get_index,
1817
get_stopper,
1918
)
@@ -133,10 +132,10 @@ def _serialize_vote(vote: Vote, generator: TermGenerator) -> Document:
133132

134133
# Store timestamp and is_featured as sortable values for ranking
135134
timestamp = sortable_serialise(vote.timestamp.timestamp())
136-
doc.add_value(SLOT_TIMESTAMP, timestamp)
135+
doc.add_value(field_to_slot("timestamp"), timestamp)
137136

138137
is_featured = sortable_serialise(int(vote.is_featured))
139-
doc.add_value(SLOT_IS_FEATURED, is_featured)
138+
doc.add_value(field_to_slot("is_featured"), is_featured)
140139

141140
# Also store is_featured as boolean term for filtering
142141
term = boolean_term("is_featured", vote.is_featured)

0 commit comments

Comments
 (0)