TECHS-Technological-Solutions / ocpi

Python implementation of the Open Charge Point Interface (OCPI)
MIT License
49 stars 15 forks source link

Default value of date_to not updating in pagination_filters #59

Open smadrigalb opened 7 months ago

smadrigalb commented 7 months ago

Hi,

First of all, I want to express my gratitude for the work done on this project and for sharing it with the community.

In the pagination_filters function, in dependencies.py, the default value for the date_to parameter is set to datetime.now(). However, this results in the date_to value being set only once, when the function is defined, and not updating with each call to the function. Consequently, subsequent calls to pagination_filters always return the same value for date_to, which is not the intended behavior.

def pagination_filters(
    date_from: datetime = Query(default=None),
    date_to: datetime = Query(default=datetime.now()),
    offset: int = Query(default=0),
    limit: int = Query(default=50),
):
    print("datetoooo")
    print(date_to)
    return {
        'date_from': date_from,
        'date_to': date_to,
        'offset': offset,
        'limit': limit,
    }
VictorTechs commented 1 month ago

Hi @smadrigalb, sorry for the very long response, if you are able to create a fix, we will review it and merge it.

IOR88 commented 1 month ago

Hi @smadrigalb we are now getting back to ocpi library maintenance, we will soon take care of the request you created, have you successfully integrated ocpi lib with your project ?