@@ -50,9 +50,7 @@ class CoreClient(AsyncBaseCoreClient):
50
50
async def all_collections (self , ** kwargs ) -> Collections :
51
51
"""Read all collections from the database."""
52
52
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 )
56
54
57
55
links = [
58
56
{
@@ -71,10 +69,8 @@ async def all_collections(self, **kwargs) -> Collections:
71
69
"href" : urljoin (base_url , "collections" ),
72
70
},
73
71
]
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 )
78
74
79
75
@overrides
80
76
async def get_collection (self , collection_id : str , ** kwargs ) -> Collection :
@@ -91,21 +87,22 @@ async def item_collection(
91
87
links = []
92
88
base_url = str (kwargs ["request" ].base_url )
93
89
94
- serialized_children , count = await self .database .get_item_collection (
90
+ items , maybe_count = await self .database .get_collection_items (
95
91
collection_id = collection_id , limit = limit , base_url = base_url
96
92
)
97
93
98
94
context_obj = None
99
95
if self .extension_is_enabled ("ContextExtension" ):
100
96
context_obj = {
101
- "returned" : count if count is not None and count < limit else limit ,
97
+ "returned" : len ( items ) ,
102
98
"limit" : limit ,
103
- "matched" : count ,
104
99
}
100
+ if maybe_count is not None :
101
+ context_obj ["matched" ] = maybe_count
105
102
106
103
return ItemCollection (
107
104
type = "FeatureCollection" ,
108
- features = serialized_children ,
105
+ features = items ,
109
106
links = links ,
110
107
context = context_obj ,
111
108
)
@@ -207,29 +204,29 @@ async def post_search(
207
204
) -> ItemCollection :
208
205
"""POST search catalog."""
209
206
base_url = str (kwargs ["request" ].base_url )
210
- search = self .database .create_search ()
207
+ search = self .database .make_search ()
211
208
212
209
if search_request .query :
213
210
for (field_name , expr ) in search_request .query .items ():
214
211
field = "properties__" + field_name
215
212
for (op , value ) in expr .items ():
216
- search = self .database .create_query_filter (
213
+ search = self .database .apply_stacql_filter (
217
214
search = search , op = op , field = field , value = value
218
215
)
219
216
220
217
if search_request .ids :
221
- search = self .database .search_ids (
218
+ search = self .database .apply_ids_filter (
222
219
search = search , item_ids = search_request .ids
223
220
)
224
221
225
222
if search_request .collections :
226
- search = self .database .filter_collections (
223
+ search = self .database .apply_collections_filter (
227
224
search = search , collection_ids = search_request .collections
228
225
)
229
226
230
227
if search_request .datetime :
231
228
datetime_search = self ._return_date (search_request .datetime )
232
- search = self .database .search_datetime (
229
+ search = self .database .apply_datetime_filter (
233
230
search = search , datetime_search = datetime_search
234
231
)
235
232
@@ -238,24 +235,22 @@ async def post_search(
238
235
if len (bbox ) == 6 :
239
236
bbox = [bbox [0 ], bbox [1 ], bbox [3 ], bbox [4 ]]
240
237
241
- search = self .database .search_bbox (search = search , bbox = bbox )
238
+ search = self .database .apply_bbox_filter (search = search , bbox = bbox )
242
239
243
240
if search_request .intersects :
244
- self .database .search_intersects (
241
+ self .database .apply_intersects_filter (
245
242
search = search , intersects = search_request .intersects
246
243
)
247
244
248
245
if search_request .sortby :
249
246
for sort in search_request .sortby :
250
247
if sort .field == "datetime" :
251
248
sort .field = "properties__datetime"
252
- search = self .database .sort_field (
249
+ search = self .database .apply_sort (
253
250
search = search , field = sort .field , direction = sort .direction
254
251
)
255
252
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 (
259
254
search = search , limit = search_request .limit , base_url = base_url
260
255
)
261
256
@@ -289,16 +284,16 @@ async def post_search(
289
284
context_obj = None
290
285
if self .extension_is_enabled ("ContextExtension" ):
291
286
context_obj = {
292
- "returned" : count if count < limit else limit ,
287
+ "returned" : len ( response_features ) ,
293
288
"limit" : limit ,
294
- "matched" : count ,
295
289
}
290
+ if maybe_count is not None :
291
+ context_obj ["matched" ] = maybe_count
296
292
297
- links = []
298
293
return ItemCollection (
299
294
type = "FeatureCollection" ,
300
295
features = response_features ,
301
- links = links ,
296
+ links = [] ,
302
297
context = context_obj ,
303
298
)
304
299
0 commit comments