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

Deploy 4.1.6 to Production #1908

Merged
merged 21 commits into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
216556a
OE-940 Pass user's age group to the client
keithbauer Jun 29, 2023
c742c9e
OE-965 Add query parameter to search facet links
keithbauer Jun 29, 2023
83d02a9
NOREF Add relevance to facets
keithbauer Jun 29, 2023
eb7673a
Merge pull request #1897 from NYPL-Simplified/MULTIREF-OE-enhancements
keithbauer Jul 6, 2023
ece3503
Merge pull request #1898 from NYPL-Simplified/develop
keithbauer Jul 6, 2023
7701b79
Add search faceted urls to search results
keithbauer Aug 7, 2023
4792584
Get the order from the url
keithbauer Aug 7, 2023
446601f
Update search facet url comment
keithbauer Aug 7, 2023
7bea960
Merge pull request #1899 from NYPL-Simplified/OE-927
keithbauer Aug 7, 2023
e850d22
Merge pull request #1900 from NYPL-Simplified/develop
keithbauer Aug 7, 2023
da3e946
NOREF Limit requests handled by workers
mwbenowitz Aug 10, 2023
32605c5
NOREF Set to desired values
mwbenowitz Aug 10, 2023
153abf5
Merge pull request #1901 from NYPL-Simplified/NOREF-limit-gunicorn-wo…
mwbenowitz Aug 11, 2023
f87fe44
Merge pull request #1902 from NYPL-Simplified/develop
mwbenowitz Aug 11, 2023
f03fefb
Set the original facet to active
keithbauer Aug 14, 2023
5c1b5d2
Test for active search facet
keithbauer Aug 14, 2023
a702a88
Merge pull request #1903 from NYPL-Simplified/OE-927
keithbauer Aug 14, 2023
e6edef5
Merge pull request #1904 from NYPL-Simplified/develop
keithbauer Aug 14, 2023
58bb111
Correctly set active search facet
keithbauer Aug 14, 2023
662cc7e
Merge pull request #1905 from NYPL-Simplified/OE-927
keithbauer Aug 15, 2023
62d2a16
Merge pull request #1906 from NYPL-Simplified/develop
keithbauer Aug 15, 2023
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
2 changes: 2 additions & 0 deletions api/authenticator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2703,6 +2703,7 @@ def oauth_authentication_callback(self, _db, params):
patron_info=patron_info,
root_lane=root_lane,
is_new=patrondata.is_new,
age_group=patron.external_type,
)
return redirect(client_redirect_uri + "#" + urllib.parse.urlencode(params))

Expand Down Expand Up @@ -2828,6 +2829,7 @@ def basic_auth_temp_token(self, params, _db):
expires_in=BasicAuthTempTokenController.TOKEN_DURATION.seconds,
root_lane=root_lane,
is_new=is_new,
age_group=patron.external_type,
)

return flask.jsonify(data)
3 changes: 3 additions & 0 deletions core/facets.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class FacetConstants(object):
ORDER_SERIES_POSITION = 'series'
ORDER_WORK_ID = 'work_id'
ORDER_RANDOM = 'random'
ORDER_RELEVANCE = 'relevance'
# Some order facets, like series and work id,
# only make sense in certain contexts.
# These are the options that can be enabled
Expand All @@ -51,6 +52,7 @@ class FacetConstants(object):
ORDER_AUTHOR,
ORDER_ADDED_TO_COLLECTION,
ORDER_RANDOM,
ORDER_RELEVANCE,
]

ORDER_ASCENDING = "asc"
Expand Down Expand Up @@ -88,6 +90,7 @@ class FacetConstants(object):
ORDER_SERIES_POSITION: _('Series Position'),
ORDER_WORK_ID : _('Work ID'),
ORDER_RANDOM : _('Random'),
ORDER_RELEVANCE : _('Relevance'),

AVAILABLE_NOW : _("Available now"),
AVAILABLE_ALL : _("All"),
Expand Down
26 changes: 22 additions & 4 deletions core/opds.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import datetime
import logging
from urllib.parse import quote
from urllib.parse import quote, parse_qsl
from collections import (
defaultdict,
)
Expand Down Expand Up @@ -1019,9 +1019,27 @@ def make_link(ep):
# Add "up" link.
AcquisitionFeed.add_link_to_feed(feed=opds_feed.feed, rel="up", href=annotator.lane_url(lane), title=str(lane.display_name))

# Add URLs to change faceted views
for args in cls.facet_links(annotator, facets):
AcquisitionFeed.add_link_to_feed(feed=opds_feed.feed, **args)
# Add URLs to change enabled faceted views
enabled_order_facets = list(facets.enabled_facets)[0]
all_order_facets = filter(
lambda facet: "Sort by" in facet.values(),
cls.facet_links(annotator, facets)
)
original_facet = facets.order
for facet in all_order_facets:
order = dict(parse_qsl(facet["href"])).get('order')
if order in enabled_order_facets:
facets.order = order
if order == original_facet:
facet = cls.facet_link(href=facet["href"], title=facet["title"], facet_group_name="Sort by", is_active=True)
else:
facet = cls.facet_link(href=facet["href"], title=facet["title"], facet_group_name="Sort by", is_active=False)
# cls.facet_links generates a /feed/ url, but we want to use
# search_url to generate a /search/ url. We also want to generate
# the facet url for this given ordering facet instead of the original facet.
facet["href"] = annotator.search_url(lane, query, pagination=None, facets=facets)
AcquisitionFeed.add_link_to_feed(feed=opds_feed.feed, **facet)
facets.order = original_facet

# We do not add breadcrumbs to this feed since you're not
# technically searching the this lane; you are searching the
Expand Down
3 changes: 3 additions & 0 deletions core/tests/test_facets.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,6 @@ def test_enable_facet(self):
config.enable_facet(order_by, Facets.ORDER_RANDOM)
assert Facets.ORDER_RANDOM in config.enabled_facets(order_by)
assert config.default_facet(order_by) != Facets.ORDER_RANDOM

config.enable_facet(order_by, Facets.ORDER_RELEVANCE)
assert Facets.ORDER_RELEVANCE in config.enabled_facets(order_by)
3 changes: 3 additions & 0 deletions core/tests/test_opds.py
Original file line number Diff line number Diff line change
Expand Up @@ -1296,6 +1296,9 @@ def make_page(pagination):
assert 'Title' in sort_by_facets
assert 'Author' in sort_by_facets

[active_facet] = [facet['title'] for facet in facets if getattr(facet, "activefacet", False) == 'true']
assert active_facet == 'Author'

# The feed has no breadcrumb links, since we're not
# searching the lane -- just using some aspects of the lane
# to guide the search.
Expand Down
2 changes: 2 additions & 0 deletions docker/gunicorn.conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
bind = ["127.0.0.1:8000"] # listen on 8000, only on the loopback address
workers = (2 * multiprocessing.cpu_count()) + 1
threads = 2
max_requests = 500
max_requests_jitter = 50
pythonpath = ",".join([
str(VENV_ACTUAL),
SIMPLIFIED_HOME,
Expand Down
4 changes: 4 additions & 0 deletions tests/test_authenticator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2474,6 +2474,7 @@ def test_authentication_creates_missing_patron(self):
permanent_id=self._str,
authorization_identifier=self._str,
fines=Money(1, "USD"),
external_type='H',
)

library = self._library()
Expand All @@ -2490,6 +2491,7 @@ def test_authentication_creates_missing_patron(self):
assert (patrondata.authorization_identifier ==
patron.authorization_identifier)
assert provider.patron_is_new is True
assert patron.external_type == patrondata.external_type

# Information not relevant to the patron's identity was stored
# in the Patron object after it was created.
Expand Down Expand Up @@ -2793,6 +2795,7 @@ def __init__(self, library, _db, external_authenticate_url, patron, root_lane=No
self.patrondata = PatronData(personal_name="Abcd", is_new=is_new)
self.root_lane = root_lane
self.is_new = self.patrondata.is_new
self.age_group = self.patron.external_type

def external_authenticate_url(self, state, _db):
return self.url + "?state=" + state
Expand Down Expand Up @@ -2878,6 +2881,7 @@ def test_oauth_authentication_callback(self):
assert self.oauth1.token.credential == provider_token
assert str(self.oauth1.root_lane) in fragments.get('root_lane')[0]
assert str(self.oauth1.is_new) == fragments.get('is_new')[0]
assert str(self.oauth1.age_group) == fragments.get('age_group')[0]

# Successful callback through OAuth provider 2.
params = dict(code="foo", state=json.dumps(dict(provider=self.oauth2.NAME)))
Expand Down
Loading