Skip to content

Commit d5e4b64

Browse files
authored
Merge branch 'main' into base-db-inherit
2 parents b1eb8e6 + fe37609 commit d5e4b64

File tree

8 files changed

+32
-21
lines changed

8 files changed

+32
-21
lines changed

CHANGELOG.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1010
### Fixed
1111
- Fixed inheritance relating to DatabaseLogic and BaseDatabaseLogic, and ApiBaseSettings [#355](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/355)
1212

13-
## [v4.0.0]
13+
## [v4.0.0a0]
1414

1515
### Added
1616
- Added support for dynamically-generated queryables based on Elasticsearch/OpenSearch mappings, with extensible metadata augmentation [#351](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/351)
@@ -20,7 +20,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
2020
- Refactored database logic to reduce duplication [#351](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/351)
2121
- Replaced `fastapi-slim` with `fastapi` dependency [#351](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/351)
2222
- Changed minimum Python version to 3.9 [#354](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/354)
23-
- Updated stac-fastapi api, types, and extensions libraries to 5.1.1 and made various associated changes [#354](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/354)
23+
- Updated stac-fastapi api, types, and extensions libraries to 5.1.1 from 3.0.0 and made various associated changes [#354](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/354)
24+
- Changed makefile commands from 'docker-compose' to 'docker compose' [#354](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/354)
2425

2526
### Fixed
2627
- Improved performance of `mk_actions` and `filter-links` methods [#351](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/351)
@@ -323,8 +324,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
323324
- Use genexp in execute_search and get_all_collections to return results.
324325
- Added db_to_stac serializer to item_collection method in core.py.
325326

326-
[Unreleased]: https://github.com/stac-utils/stac-fastapi-elasticsearch/tree/v4.0.0...main
327-
[v4.0.0]: https://github.com/stac-utils/stac-fastapi-elasticsearch/tree/v3.2.4...v4.0.0
327+
[Unreleased]: https://github.com/stac-utils/stac-fastapi-elasticsearch/tree/v4.0.0a0...main
328+
[v4.0.0a0]: https://github.com/stac-utils/stac-fastapi-elasticsearch/tree/v3.2.5...v4.0.0a0
328329
[v3.2.5]: https://github.com/stac-utils/stac-fastapi-elasticsearch/tree/v3.2.4...v3.2.5
329330
[v3.2.4]: https://github.com/stac-utils/stac-fastapi-elasticsearch/tree/v3.2.3...v3.2.4
330331
[v3.2.3]: https://github.com/stac-utils/stac-fastapi-elasticsearch/tree/v3.2.2...v3.2.3

stac_fastapi/core/stac_fastapi/core/core.py

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
from stac_fastapi.types.core import AsyncBaseCoreClient, AsyncBaseTransactionsClient
3838
from stac_fastapi.types.extension import ApiExtension
3939
from stac_fastapi.types.requests import get_base_url
40-
from stac_fastapi.types.rfc3339 import DateTimeType
40+
from stac_fastapi.types.rfc3339 import DateTimeType, rfc3339_str_to_datetime
4141
from stac_fastapi.types.search import BaseSearchPostRequest
4242

4343
logger = logging.getLogger(__name__)
@@ -428,18 +428,31 @@ def _return_date(
428428

429429
def _format_datetime_range(self, date_str: str) -> str:
430430
"""
431-
Convert a datetime range into a formatted string.
431+
Convert a datetime range string into a normalized UTC string for API requests using rfc3339_str_to_datetime.
432432
433433
Args:
434-
date_tuple (str): A string containing two datetime values separated by a '/'.
434+
date_str (str): A string containing two datetime values separated by a '/'.
435435
436436
Returns:
437-
str: A string formatted as 'YYYY-MM-DDTHH:MM:SS.sssZ/YYYY-MM-DDTHH:MM:SS.sssZ', with '..' used if any element is None.
437+
str: A string formatted as 'YYYY-MM-DDTHH:MM:SSZ/YYYY-MM-DDTHH:MM:SSZ', with '..' used if any element is None.
438438
"""
439-
start, end = date_str.split("/")
440-
start = start.replace("+01:00", "Z") if start else ".."
441-
end = end.replace("+01:00", "Z") if end else ".."
442-
return f"{start}/{end}"
439+
def normalize(dt):
440+
dt = dt.strip()
441+
if not dt or dt == "..":
442+
return ".."
443+
dt_obj = rfc3339_str_to_datetime(dt)
444+
dt_utc = dt_obj.astimezone(timezone.utc)
445+
return dt_utc.strftime("%Y-%m-%dT%H:%M:%SZ")
446+
447+
if not isinstance(date_str, str):
448+
return "../.."
449+
if "/" not in date_str:
450+
return f"{normalize(date_str)}/{normalize(date_str)}"
451+
try:
452+
start, end = date_str.split("/", 1)
453+
except Exception:
454+
return "../.."
455+
return f"{normalize(start)}/{normalize(end)}"
443456

444457
async def get_search(
445458
self,
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
"""library version."""
2-
__version__ = "4.0.0"
2+
__version__ = "4.0.0a0"

stac_fastapi/elasticsearch/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
desc = f.read()
77

88
install_requires = [
9-
"stac-fastapi.core==4.0.0",
9+
"stac-fastapi.core==4.0.0a0",
1010
"elasticsearch[async]==8.11.0",
1111
"elasticsearch-dsl==8.11.0",
1212
"uvicorn",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
"""library version."""
2-
__version__ = "4.0.0"
2+
__version__ = "4.0.0a0"

stac_fastapi/opensearch/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
desc = f.read()
77

88
install_requires = [
9-
"stac-fastapi.core==4.0.0",
9+
"stac-fastapi.core==4.0.0a0",
1010
"opensearch-py==2.4.2",
1111
"opensearch-py[async]==2.4.2",
1212
"uvicorn",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
"""library version."""
2-
__version__ = "4.0.0"
2+
__version__ = "4.0.0a0"

stac_fastapi/tests/resources/test_item.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import os
33
import uuid
44
from copy import deepcopy
5-
from datetime import datetime, timedelta, timezone
5+
from datetime import datetime, timedelta
66
from random import randint
77
from urllib.parse import parse_qs, urlparse, urlsplit
88

@@ -478,13 +478,10 @@ async def test_item_search_temporal_window_timezone_get(
478478
app_client, ctx, load_test_data
479479
):
480480
"""Test GET search with spatio-temporal query ending with Zulu and pagination(core)"""
481-
tzinfo = timezone(timedelta(hours=1))
482481
test_item = load_test_data("test_item.json")
483482
item_date = rfc3339_str_to_datetime(test_item["properties"]["datetime"])
484483
item_date_before = item_date - timedelta(seconds=1)
485-
item_date_before = item_date_before.replace(tzinfo=tzinfo)
486484
item_date_after = item_date + timedelta(seconds=1)
487-
item_date_after = item_date_after.replace(tzinfo=tzinfo)
488485

489486
params = {
490487
"collections": test_item["collection"],

0 commit comments

Comments
 (0)