Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix search filter for 'All' languages facet #21

Merged
merged 1 commit into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions core/lane.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,9 +553,7 @@ def __init__(
self.collection_name = collection_name or self.default_facet(
library, self.COLLECTION_NAME_FACETS_GROUP_NAME
)
self.language: str = language or self.default_facet(
library, self.LANGUAGE_FACET_GROUP_NAME
)
self.language: str = language
if order_ascending == self.ORDER_ASCENDING:
order_ascending = True
elif order_ascending == self.ORDER_DESCENDING:
Expand Down Expand Up @@ -727,7 +725,9 @@ def modify_search_filter(self, filter):
filter.subcollection = self.collection

# Finland
if self.language and self.language != self.LANGUAGE_ALL:
if self.language == self.LANGUAGE_ALL:
filter.languages = []
elif self.language:
filter.languages = [self.language]

# We can only have distributor and collection name facets if we have a library
Expand Down
2 changes: 1 addition & 1 deletion tests/api/feed/test_opds_acquisition_feed.py
Original file line number Diff line number Diff line change
Expand Up @@ -1151,7 +1151,7 @@ def run(wl=None, facets=None, pagination=None):
# The make_link function that was passed in calls
# TestAnnotator.feed_url() when passed an EntryPoint. The
# Facets object's other facet groups are propagated in this URL.
first_page_url = "http://wl/?available=all&collection=full&collectionName=All&distributor=All&entrypoint=Book&language=all&order=author"
first_page_url = "http://wl/?available=all&collection=full&collectionName=All&distributor=All&entrypoint=Book&order=author"
assert first_page_url == make_link(EbooksEntryPoint)

# Pagination information is not propagated through entry point links
Expand Down
4 changes: 2 additions & 2 deletions tests/api/test_lanes.py
Original file line number Diff line number Diff line change
Expand Up @@ -908,7 +908,7 @@ def test_default(self, db: DatabaseTransactionFixture):
assert facets.collection == CrawlableFacets.COLLECTION_FULL
assert facets.availability == CrawlableFacets.AVAILABLE_ALL
assert facets.order == CrawlableFacets.ORDER_LAST_UPDATE
assert facets.language == CrawlableFacets.LANGUAGE_ALL
assert facets.language is None
assert facets.order_ascending is False

[
Expand All @@ -921,7 +921,7 @@ def test_default(self, db: DatabaseTransactionFixture):
] = facets.enabled_facets

# The default facets are the only ones enabled.
for facet in [order, availability, collection, language]:
for facet in [order, availability, collection]:
assert len(facet) == 1

# Except for distributor and collectionName, which have the default
Expand Down
2 changes: 1 addition & 1 deletion tests/core/test_lane.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ def test_facet_groups(self, db: DatabaseTransactionFixture):
["collectionName", db.default_collection().name, False],
["distributor", "All", True],
["distributor", DataSource.AMAZON, False],
["language", "all", True],
["language", "all", False],
["language", "eng", False],
["language", "fin", False],
["language", "others", False],
Expand Down