@@ -50,9 +50,7 @@ class CoreClient(AsyncBaseCoreClient):
5050 async def all_collections (self , ** kwargs ) -> Collections :
5151 """Read all collections from the database."""
5252 base_url = str (kwargs ["request" ].base_url )
53- serialized_collections = await self .database .get_all_collections (
54- base_url = base_url
55- )
53+ collection_list = await self .database .get_all_collections (base_url = base_url )
5654
5755 links = [
5856 {
@@ -71,10 +69,8 @@ async def all_collections(self, **kwargs) -> Collections:
7169 "href" : urljoin (base_url , "collections" ),
7270 },
7371 ]
74- collection_list = Collections (
75- collections = serialized_collections or [], links = links
76- )
77- return collection_list
72+
73+ return Collections (collections = collection_list , links = links )
7874
7975 @overrides
8076 async def get_collection (self , collection_id : str , ** kwargs ) -> Collection :
@@ -91,21 +87,22 @@ async def item_collection(
9187 links = []
9288 base_url = str (kwargs ["request" ].base_url )
9389
94- serialized_children , count = await self .database .get_item_collection (
90+ items , maybe_count = await self .database .get_collection_items (
9591 collection_id = collection_id , limit = limit , base_url = base_url
9692 )
9793
9894 context_obj = None
9995 if self .extension_is_enabled ("ContextExtension" ):
10096 context_obj = {
101- "returned" : count if count is not None and count < limit else limit ,
97+ "returned" : len ( items ) ,
10298 "limit" : limit ,
103- "matched" : count ,
10499 }
100+ if maybe_count is not None :
101+ context_obj ["matched" ] = maybe_count
105102
106103 return ItemCollection (
107104 type = "FeatureCollection" ,
108- features = serialized_children ,
105+ features = items ,
109106 links = links ,
110107 context = context_obj ,
111108 )
@@ -207,29 +204,29 @@ async def post_search(
207204 ) -> ItemCollection :
208205 """POST search catalog."""
209206 base_url = str (kwargs ["request" ].base_url )
210- search = self .database .create_search ()
207+ search = self .database .make_search ()
211208
212209 if search_request .query :
213210 for (field_name , expr ) in search_request .query .items ():
214211 field = "properties__" + field_name
215212 for (op , value ) in expr .items ():
216- search = self .database .create_query_filter (
213+ search = self .database .apply_stacql_filter (
217214 search = search , op = op , field = field , value = value
218215 )
219216
220217 if search_request .ids :
221- search = self .database .search_ids (
218+ search = self .database .apply_ids_filter (
222219 search = search , item_ids = search_request .ids
223220 )
224221
225222 if search_request .collections :
226- search = self .database .filter_collections (
223+ search = self .database .apply_collections_filter (
227224 search = search , collection_ids = search_request .collections
228225 )
229226
230227 if search_request .datetime :
231228 datetime_search = self ._return_date (search_request .datetime )
232- search = self .database .search_datetime (
229+ search = self .database .apply_datetime_filter (
233230 search = search , datetime_search = datetime_search
234231 )
235232
@@ -238,24 +235,22 @@ async def post_search(
238235 if len (bbox ) == 6 :
239236 bbox = [bbox [0 ], bbox [1 ], bbox [3 ], bbox [4 ]]
240237
241- search = self .database .search_bbox (search = search , bbox = bbox )
238+ search = self .database .apply_bbox_filter (search = search , bbox = bbox )
242239
243240 if search_request .intersects :
244- self .database .search_intersects (
241+ self .database .apply_intersects_filter (
245242 search = search , intersects = search_request .intersects
246243 )
247244
248245 if search_request .sortby :
249246 for sort in search_request .sortby :
250247 if sort .field == "datetime" :
251248 sort .field = "properties__datetime"
252- search = self .database .sort_field (
249+ search = self .database .apply_sort (
253250 search = search , field = sort .field , direction = sort .direction
254251 )
255252
256- count = await self .database .search_count (search = search )
257-
258- response_features = await self .database .execute_search (
253+ response_features , maybe_count = await self .database .execute_search (
259254 search = search , limit = search_request .limit , base_url = base_url
260255 )
261256
@@ -289,16 +284,16 @@ async def post_search(
289284 context_obj = None
290285 if self .extension_is_enabled ("ContextExtension" ):
291286 context_obj = {
292- "returned" : count if count < limit else limit ,
287+ "returned" : len ( response_features ) ,
293288 "limit" : limit ,
294- "matched" : count ,
295289 }
290+ if maybe_count is not None :
291+ context_obj ["matched" ] = maybe_count
296292
297- links = []
298293 return ItemCollection (
299294 type = "FeatureCollection" ,
300295 features = response_features ,
301- links = links ,
296+ links = [] ,
302297 context = context_obj ,
303298 )
304299
0 commit comments