stac-pydantic icon indicating copy to clipboard operation
stac-pydantic copied to clipboard

fix(search): clear datetime between searches

Open sbrunato opened this issue 9 months ago • 3 comments

Fixes https://github.com/stac-utils/stac-pydantic/issues/170

Clears _start_date and _end_date Search class variables between model instances.

sbrunato avatar Feb 25 '25 13:02 sbrunato

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 96.20%. Comparing base (a927d25) to head (274d083). Report is 81 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #171      +/-   ##
==========================================
- Coverage   96.59%   96.20%   -0.39%     
==========================================
  Files          25       25              
  Lines         587      606      +19     
==========================================
+ Hits          567      583      +16     
- Misses         20       23       +3     
Flag Coverage Δ
unittests 96.20% <100.00%> (-0.39%) :arrow_down:

Flags with carried forward coverage won't be shown. Click here to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov-commenter avatar Feb 25 '25 16:02 codecov-commenter

Thanks for the PR @sbrunato 🙏

I feel we will have the same problem in https://github.com/stac-utils/stac-fastapi/blob/c71a355c46e53af40cd9ebe23bc151fa9faf8776/stac_fastapi/extensions/stac_fastapi/extensions/core/collection_search/request.py#L114-L156

To me it seems weird that the class attribute are not reseted to None on class initialization. I guess there is something I don't understand 🤔

vincentsarago avatar Feb 25 '25 17:02 vincentsarago

I feel we will have the same problem in https://github.com/stac-utils/stac-fastapi/blob/c71a355c46e53af40cd9ebe23bc151fa9faf8776/stac_fastapi/extensions/stac_fastapi/extensions/core/collection_search/request.py#L114-L156

Yes, there is exactly the same issue in collection_search.

To me it seems weird that the class attribute are not reseted to None on class initialization.

I think that is because the attributes belong to the class, and are persistent through each new instantiation. Like in this:

>>> class Foo:
...     bar = None
... 
>>> Foo().bar
>>> Foo.bar = 1
>>> Foo().bar
1

sbrunato avatar Feb 25 '25 18:02 sbrunato