File tree Expand file tree Collapse file tree 2 files changed +29
-26
lines changed
Expand file tree Collapse file tree 2 files changed +29
-26
lines changed Original file line number Diff line number Diff line change @@ -64,14 +64,13 @@ def test_items_limit_and_offset(app):
6464 assert body ["numberReturned" ] == 1
6565 assert ["collection" , "self" , "prev" ] == [link ["rel" ] for link in body ["links" ]]
6666
67- # TODO: Fix
68- # offset > data
69- # response = app.get("/collections/public.landsat_wrs/items?offset=20000")
70- # assert response.status_code == 200
71- # body = response.json()
72- # assert len(body["features"]) == 0
73- # assert body["numberMatched"] == 16269
74- # assert body["numberReturned"] == 0
67+ # offset overflow, return empty feature collection
68+ response = app .get ("/collections/public.landsat_wrs/items?offset=20000" )
69+ assert response .status_code == 200
70+ body = response .json ()
71+ assert len (body ["features" ]) == 0
72+ assert body ["numberMatched" ] == 16269
73+ assert body ["numberReturned" ] == 0
7574
7675
7776def test_items_bbox (app ):
Original file line number Diff line number Diff line change @@ -376,18 +376,25 @@ async def query(
376376 )
377377 SELECT json_build_object(
378378 'type', 'FeatureCollection',
379- 'features', json_agg(
380- json_build_object(
381- 'type', 'Feature',
382- 'id', :id_column,
383- 'geometry', :geometry_q,
384- 'properties', to_jsonb( features.* ) - :geom_columns::text[]
379+ 'features',
380+ (
381+ SELECT
382+ json_agg(
383+ json_build_object(
384+ 'type', 'Feature',
385+ 'id', :id_column,
386+ 'geometry', :geometry_q,
387+ 'properties', to_jsonb( features.* ) - :geom_columns::text[]
388+ )
389+ )
390+ FROM features
391+ ),
392+ 'total_count',
393+ (
394+ SELECT count FROM total_count
385395 )
386- ),
387- 'total_count', total_count.count
388- )
389- FROM features, total_count
390- GROUP BY total_count.count;
396+ )
397+ ;
391398 """
392399 q , p = render (
393400 sql_query ,
@@ -424,13 +431,10 @@ async def query(
424431 async with pool .acquire () as conn :
425432 items = await conn .fetchval (q , * p )
426433
427- if items :
428- return (
429- FeatureCollection (features = items ["features" ]),
430- items ["total_count" ],
431- )
432- else :
433- return FeatureCollection (features = []), 0
434+ return (
435+ FeatureCollection (features = items .get ("features" ) or []),
436+ items ["total_count" ],
437+ )
434438
435439 async def features (
436440 self ,
You can’t perform that action at this time.
0 commit comments