Skip to content

Commit c88fcd0

Browse files
fix filter condition
1 parent f2665ca commit c88fcd0

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

stac_fastapi/core/stac_fastapi/core/extensions/aggregation.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,8 @@ async def aggregate(
447447
status_code=400,
448448
detail=f"Aggregation {agg_name} not supported at catalog level",
449449
)
450+
451+
if aggregate_request.filter:
450452
try:
451453
search = self.database.apply_cql2_filter(
452454
search, aggregate_request.filter

stac_fastapi/tests/extensions/test_aggregation.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,19 @@ async def test_aggregate_filter_extension_eq_post(app_client, ctx):
176176
assert resp.json()["aggregations"][0]["value"] == 1
177177

178178

179+
@pytest.mark.asyncio
180+
async def test_aggregate_filter_extension_neq_post(app_client, ctx):
181+
params = {
182+
"filter": {"op": "<>", "args": [{"property": "id"}, ctx.item["id"]]},
183+
"filter-lang": "cql2-json",
184+
"aggregations": ["total_count"],
185+
"collections": [ctx.item["collection"]],
186+
}
187+
resp = await app_client.post("/aggregate", json=params)
188+
assert resp.status_code == 200
189+
assert resp.json()["aggregations"][0]["value"] == 0
190+
191+
179192
@pytest.mark.asyncio
180193
async def test_aggregate_extension_gte_get(app_client, ctx):
181194
# there's one item that can match, so one of these queries should match it and the other shouldn't

0 commit comments

Comments
 (0)