Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/api/v1/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class TagsBodyParams(BaseModel):
class ResampleQueryParams:
def __init__(
self,
sample_rate: int = Query(..., description="Sample Rate", example=5),
sample_rate: str = Query(..., description="Sample Rate", example=5),
sample_unit: str = Query(..., description="Sample Unit", examples={"second": {"value": "second"}, "minute": {"value": "minute"}, "hour": {"value": "hour"}, "day": {"value": "day"}}),
agg_method: str = Query(..., description="Aggregation Method", examples={"first": {"value": "first"}, "last": {"value": "last"}, "avg": {"value": "avg"}, "min": {"value": "min"}, "max": {"value": "max"}}),
):
Expand Down
9 changes: 8 additions & 1 deletion src/sdk/python/rtdip_sdk/functions/_query_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ def _is_date_format(dt, format):
def _parse_date(dt, is_end_date=False, exclude_date_format=False):
if isinstance(dt, datetime):
if dt.time() == time.min:
dt = dt.date()
if dt.tzinfo is not None:
dt = datetime.strftime(dt, "%Y-%m-%d%z")
else:
dt = dt.date()
else:
dt = datetime.strftime(dt, "%Y-%m-%dT%H:%M:%S%z")
dt = str(dt)
Expand All @@ -40,6 +43,10 @@ def _parse_date(dt, is_end_date=False, exclude_date_format=False):
return dt + "+0000"
elif _is_date_format(dt, "%Y-%m-%dT%H:%M:%S%z"):
return dt
elif _is_date_format(dt, "%Y-%m-%d%z"):
_time = "T23:59:59" if is_end_date == True else "T00:00:00"
dt = dt[0:10] + _time + dt[10:]
return dt
else:
msg = f"Inputted timestamp: '{dt}', is not in the correct format."
if exclude_date_format == True:
Expand Down
4 changes: 2 additions & 2 deletions tests/api/v1/api_test_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@
RESAMPLE_MOCKED_PARAMETER_DICT = RAW_MOCKED_PARAMETER_DICT.copy()
RESAMPLE_MOCKED_PARAMETER_ERROR_DICT = RAW_MOCKED_PARAMETER_ERROR_DICT.copy()

RESAMPLE_MOCKED_PARAMETER_DICT["sample_rate"] = 1
RESAMPLE_MOCKED_PARAMETER_DICT["sample_rate"] = "1"
RESAMPLE_MOCKED_PARAMETER_DICT["sample_unit"] = "minute"
RESAMPLE_MOCKED_PARAMETER_DICT["agg_method"] = "avg"
RESAMPLE_MOCKED_PARAMETER_ERROR_DICT["sample_rate"] = 1
RESAMPLE_MOCKED_PARAMETER_ERROR_DICT["sample_rate"] = "1"
RESAMPLE_MOCKED_PARAMETER_ERROR_DICT["sample_unit"] = "minute"
RESAMPLE_MOCKED_PARAMETER_ERROR_DICT["agg_method"] = "avg"

Expand Down