Skip to content

Commit

Permalink
Merge pull request #7 from PADAS/gundi-3699-fix-handlers-return
Browse files Browse the repository at this point in the history
GUNDI-3699: Fix return type issue in handlers
  • Loading branch information
marianobrc authored Nov 13, 2024
2 parents 46cfc1c + 782ae73 commit 21d8ad0
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions app/actions/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ async def action_fetch_samples(integration, action_config: FetchSamplesConfig):
async def action_pull_observations(integration, action_config: PullObservationsConfig):
logger.info(f"Executing pull_observations action with integration {integration} and action_config {action_config}...")
try:
result = {"observations_extracted": 0, "details": {}}
async for attempt in stamina.retry_context(
on=httpx.HTTPError,
attempts=3,
Expand All @@ -134,6 +135,7 @@ async def action_pull_observations(integration, action_config: PullObservationsC
"pull_observations"
)

total_observations = 0
if transformed_data:
async for attempt in stamina.retry_context(
on=httpx.HTTPError,
Expand All @@ -157,8 +159,10 @@ async def action_pull_observations(integration, action_config: PullObservationsC
'action_id': "pull_observations"
}
)
return [msg]
result["message"] = msg
return result
else:
total_observations += len(transformed_data)
for vehicle in transformed_data:
# Update state
state = {
Expand All @@ -172,7 +176,7 @@ async def action_pull_observations(integration, action_config: PullObservationsC
)

else:
response = []
result["message"] = "No transformed data to send."
except httpx.HTTPError as e:
message = f"pull_observations action returned error."
logger.exception(message, extra={
Expand All @@ -181,4 +185,6 @@ async def action_pull_observations(integration, action_config: PullObservationsC
})
raise e
else:
return response
result["observations_extracted"] = total_observations
result["details"] = response
return result

0 comments on commit 21d8ad0

Please sign in to comment.