File tree Expand file tree Collapse file tree 6 files changed +32
-3
lines changed Expand file tree Collapse file tree 6 files changed +32
-3
lines changed Original file line number Diff line number Diff line change 267267 <!-- additional fields used by documents of type subject -->
268268 <field name =" subject_type" type =" string" indexed =" true" stored =" true" />
269269
270+ <!-- fields used by documents of type list -->
271+ <field name =" last_modified" type =" pdate" indexed =" true" stored =" true" />
272+ <field name =" seed_count" type =" pint" indexed =" true" stored =" true" />
273+
270274 <!-- dynamic fields -->
271275 <dynamicField name =" id_*" type =" string" indexed =" true" stored =" true" multiValued =" true" />
272276
Original file line number Diff line number Diff line change @@ -734,7 +734,7 @@ class list_search(delegate.page):
734734 path = '/search/lists'
735735
736736 def GET (self ): # referenced subject_search
737- req = ListSearchRequest .from_web_input (web .input (api = 'new ' ))
737+ req = ListSearchRequest .from_web_input (web .input (api = 'next ' ))
738738 # Can't set fields when rendering html
739739 req .fields = 'key'
740740 resp = self .get_results (req , 'LIST_SEARCH' )
Original file line number Diff line number Diff line change @@ -26,6 +26,8 @@ class ListSearchScheme(SearchScheme):
2626 'place_key' ,
2727 'time' ,
2828 'time_key' ,
29+ 'last_modified' ,
30+ 'seed_count' ,
2931 }
3032 )
3133
@@ -36,7 +38,13 @@ class ListSearchScheme(SearchScheme):
3638 field_name_map = MappingProxyType ({})
3739 sorts = MappingProxyType (
3840 {
39- 'name asc' : 'name asc' , # sort alphabetically
41+ 'name asc' : 'name asc' ,
42+ 'last_modified' : 'last_modified desc' ,
43+ 'last_modified asc' : 'last_modified asc' ,
44+ 'last_modified desc' : 'last_modified desc' ,
45+ 'seed_count' : 'seed_count desc' ,
46+ 'seed_count asc' : 'seed_count asc' ,
47+ 'seed_count desc' : 'seed_count desc' ,
4048 # Random (kept from SubjectSearchScheme)
4149 'random' : 'random_1 asc' ,
4250 'random asc' : 'random_1 asc' ,
Original file line number Diff line number Diff line change 11# This file is auto-generated by types_generator.py
2+ # To regenerate:
3+ # python openlibrary/solr/types_generator.py > openlibrary/solr/solr_types.py
24# fmt: off
35# ruff: noqa: UP045
46from typing import Literal , Optional , TypedDict
@@ -121,6 +123,8 @@ class SolrDocument(TypedDict):
121123 top_work : Optional [str ]
122124 top_subjects : Optional [list [str ]]
123125 subject_type : Optional [str ]
126+ last_modified : Optional [str ]
127+ seed_count : Optional [int ]
124128 public_scan_b : Optional [bool ]
125129 printdisabled_s : Optional [str ]
126130 lending_edition_s : Optional [str ]
Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ def generate():
3131 typ = field .get ('type' )
3232 multivalued = field .get ('multiValued' ) == 'true'
3333 type_map = {
34+ 'pdate' : 'str' ,
3435 'pint' : 'int' ,
3536 'string' : 'str' ,
3637 'text_en_splitting' : 'str' ,
@@ -81,6 +82,8 @@ def generate():
8182
8283 body = '\n ' .join (python_fields )
8384 python = f"""# This file is auto-generated by types_generator.py
85+ # To regenerate:
86+ # python openlibrary/solr/types_generator.py > openlibrary/solr/solr_types.py
8487# fmt: off
8588# ruff: noqa: UP045
8689from typing import Literal, Optional, TypedDict
Original file line number Diff line number Diff line change 11import re
22from collections import defaultdict
3+ from functools import cached_property
34from typing import cast
45
56import httpx
@@ -106,7 +107,7 @@ def type(self) -> str:
106107 def name (self ) -> str | None :
107108 return self ._list .get ('name' )
108109
109- @property
110+ @cached_property
110111 def seed (self ) -> list [str ]:
111112 return [
112113 (
@@ -116,3 +117,12 @@ def seed(self) -> list[str]:
116117 )
117118 for seed in self ._list .get ('seeds' , [])
118119 ]
120+
121+ @property
122+ def last_modified (self ) -> str :
123+ # Solr expects UTC ISO 8601 with 'Z' suffix, e.g. 2024-12-09T12:57:14.074200Z
124+ return self ._list ['last_modified' ]['value' ] + 'Z'
125+
126+ @property
127+ def seed_count (self ) -> int :
128+ return len (self .seed )
You can’t perform that action at this time.
0 commit comments