Skip to content

Commit 893ed7f

Browse files
committed
alias not working?
1 parent e06f8c0 commit 893ed7f

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -389,9 +389,9 @@ async def aggregate(
389389
collection_id = path.split("/")[2]
390390

391391
filter_lang = "cql2-json"
392-
if aggregate_request.filter:
393-
aggregate_request.filter = self.get_filter(
394-
aggregate_request.filter, filter_lang
392+
if aggregate_request.filter_expr:
393+
aggregate_request.filter_expr = self.get_filter(
394+
aggregate_request.filter_expr, filter_lang
395395
)
396396

397397
if collection_id:
@@ -465,10 +465,10 @@ async def aggregate(
465465
detail=f"Aggregation {agg_name} not supported at catalog level",
466466
)
467467

468-
if aggregate_request.filter:
468+
if aggregate_request.filter_expr:
469469
try:
470470
search = self.database.apply_cql2_filter(
471-
search, aggregate_request.filter
471+
search, aggregate_request.filter_expr
472472
)
473473
except Exception as e:
474474
raise HTTPException(

stac_fastapi/tests/extensions/test_aggregation.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,8 @@ async def test_aggregate_datetime_in_range(app_client, ctx):
178178
@pytest.mark.asyncio
179179
async def test_aggregate_filter_extension_eq_post(app_client, ctx):
180180
params = {
181-
"filter": {"op": "=", "args": [{"property": "id"}, ctx.item["id"]]},
182-
"filter-lang": "cql2-json",
181+
"filter_expr": {"op": "=", "args": [{"property": "id"}, ctx.item["id"]]},
182+
"filter_lang": "cql2-json",
183183
"aggregations": ["total_count"],
184184
}
185185
resp = await app_client.post("/aggregate", json=params)
@@ -190,8 +190,8 @@ async def test_aggregate_filter_extension_eq_post(app_client, ctx):
190190
@pytest.mark.asyncio
191191
async def test_aggregate_filter_extension_neq_post(app_client, ctx):
192192
params = {
193-
"filter": {"op": "<>", "args": [{"property": "id"}, ctx.item["id"]]},
194-
"filter-lang": "cql2-json",
193+
"filter_expr": {"op": "<>", "args": [{"property": "id"}, ctx.item["id"]]},
194+
"filter_lang": "cql2-json",
195195
"aggregations": ["total_count"],
196196
"collections": [ctx.item["collection"]],
197197
}
@@ -222,14 +222,14 @@ async def test_aggregate_extension_gte_get(app_client, ctx):
222222
async def test_aggregate_filter_extension_gte_post(app_client, ctx):
223223
# there's one item that can match, so one of these queries should match it and the other shouldn't
224224
params = {
225-
"filter": {
225+
"filter_expr": {
226226
"op": "<=",
227227
"args": [
228228
{"property": "properties.proj:epsg"},
229229
ctx.item["properties"]["proj:epsg"],
230230
],
231231
},
232-
"filter-lang": "cql2-json",
232+
"filter_lang": "cql2-json",
233233
"aggregations": ["total_count"],
234234
}
235235
resp = await app_client.post("/aggregate", json=params)
@@ -238,14 +238,14 @@ async def test_aggregate_filter_extension_gte_post(app_client, ctx):
238238
assert resp.json()["aggregations"][0]["value"] == 1
239239

240240
params = {
241-
"filter": {
241+
"filter_expr": {
242242
"op": ">",
243243
"args": [
244244
{"property": "properties.proj:epsg"},
245245
ctx.item["properties"]["proj:epsg"],
246246
],
247247
},
248-
"filter-lang": "cql2-json",
248+
"filter_lang": "cql2-json",
249249
"aggregations": ["total_count"],
250250
}
251251
resp = await app_client.post("/aggregate", json=params)
@@ -271,7 +271,7 @@ async def test_search_aggregate_extension_wildcard_cql2(app_client, ctx):
271271
multi_char = ctx.item["id"][:-3] + "%"
272272

273273
params = {
274-
"filter": {
274+
"filter_expr": {
275275
"op": "and",
276276
"args": [
277277
{"op": "=", "args": [{"property": "id"}, ctx.item["id"]]},
@@ -291,7 +291,7 @@ async def test_search_aggregate_extension_wildcard_cql2(app_client, ctx):
291291
},
292292
],
293293
},
294-
"filter-lang": "cql2-json",
294+
"filter_lang": "cql2-json",
295295
"aggregations": ["total_count"],
296296
}
297297

@@ -307,7 +307,7 @@ async def test_aggregate_filter_extension_wildcard_es(app_client, ctx):
307307
multi_char = ctx.item["id"][:-3] + "*"
308308

309309
params = {
310-
"filter": {
310+
"filter_expr": {
311311
"op": "and",
312312
"args": [
313313
{"op": "=", "args": [{"property": "id"}, ctx.item["id"]]},
@@ -327,7 +327,7 @@ async def test_aggregate_filter_extension_wildcard_es(app_client, ctx):
327327
},
328328
],
329329
},
330-
"filter-lang": "cql2-json",
330+
"filter_lang": "cql2-json",
331331
"aggregations": ["total_count"],
332332
}
333333

@@ -370,7 +370,7 @@ async def test_aggregate_filter_extension_in_no_list(app_client, ctx):
370370
product_id = ctx.item["properties"]["landsat:product_id"]
371371

372372
params = {
373-
"filter": {
373+
"filter_expr": {
374374
"op": "and",
375375
"args": [
376376
{"op": "=", "args": [{"property": "id"}, ctx.item["id"]]},
@@ -383,7 +383,7 @@ async def test_aggregate_filter_extension_in_no_list(app_client, ctx):
383383
},
384384
],
385385
},
386-
"filter-lang": "cql2-json",
386+
"filter_lang": "cql2-json",
387387
"aggregations": ["total_count"],
388388
}
389389

0 commit comments

Comments
 (0)