Skip to content

Commit e5b03c5

Browse files
authored
Merge pull request internetarchive#11152 from cdrini/11123/fix/subject-people-pages
Fix people/place/time subject pages erroring
2 parents dee6fb0 + 6ff68a6 commit e5b03c5

File tree

4 files changed

+11
-3
lines changed

4 files changed

+11
-3
lines changed

openlibrary/core/models.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,6 +1167,10 @@ def remove_user(self, userkey):
11671167

11681168
class Subject(web.storage):
11691169
key: str
1170+
name: str
1171+
subject_type: str
1172+
solr_query: str
1173+
"""Query with normalized subject key to get matching books; eg 'person_key:ned_wilcox'"""
11701174

11711175
def get_lists(self, limit=1000, offset=0, sort=True):
11721176
q = {

openlibrary/plugins/worksearch/subjects.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,10 @@ def get_subject(
315315
key=key,
316316
name=name,
317317
subject_type=subject_type,
318+
solr_query=query_dict_to_str(
319+
{meta.facet_key: self.normalize_key(path)},
320+
phrase=True,
321+
),
318322
work_count=result.num_found,
319323
works=add_availability([self.work_wrapper(d) for d in result.docs]),
320324
)

openlibrary/templates/publishers/view.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ <h1>
2121
</div>
2222

2323
<div class="contentBody">
24-
$:macros.QueryCarousel(query='publisher_facet:"%s"' % page.name.replace('"', '\\"'), sort='trending,trending_score_hourly_sum', user_lang_only=False, has_fulltext_only=False)
24+
$:macros.QueryCarousel(query=page.solr_query, sort='trending,trending_score_hourly_sum', user_lang_only=False, has_fulltext_only=False)
2525

2626
<div class="head">
2727
<h2>

openlibrary/templates/subjects.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ <h1 class="inline">
2828
</h1>
2929
<span class="heading">
3030
<span class="count" id="coversCount">
31-
<strong><span><a href="/search?$page.subject_type=$page.name.replace('&','%26')" title="$_('See all works')">$ungettext("%(count)d work", "%(count)d works", page.work_count, count=page.work_count)</a></span></strong>
31+
<strong><span><a href="/search?$urlencode(dict(q=page.solr_query))" title="$_('See all works')">$ungettext("%(count)d work", "%(count)d works", page.work_count, count=page.work_count)</a></span></strong>
3232
</span>
3333
</span>
3434
$if has_tag:
@@ -56,7 +56,7 @@ <h3>$_("Disambiguations")</h3>
5656
$if has_tag:
5757
$:format(sanitize(page.tag.body))
5858

59-
$:macros.QueryCarousel(query="subject_key:%s" % page.key.split('/')[-1], sort='trending,trending_score_hourly_sum', user_lang_only=True, fallback=True)
59+
$:macros.QueryCarousel(query=page.solr_query, sort='trending,trending_score_hourly_sum', user_lang_only=True, fallback=True)
6060
$:macros.PublishingHistory(page.publishing_history)
6161

6262
<div class="clearfix"></div>

0 commit comments

Comments
 (0)