Skip to content

Commit

Permalink
properly handle include_details=False
Browse files Browse the repository at this point in the history
  • Loading branch information
atmorling committed Nov 27, 2024
1 parent 675befc commit 0c9fc24
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
9 changes: 4 additions & 5 deletions ecoscope/io/async_earthranger.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,10 +419,7 @@ async def get_patrol_observations_with_patrol_filter(
relocations : ecoscope.base.Relocations
"""
observations = ecoscope.base.Relocations()
df_pt = None

if include_patrol_details:
df_pt = await self.get_patrol_types_dataframe()
df_pt = await self.get_patrol_types_dataframe() if include_patrol_details else None

tasks = []
async for patrol in self.get_patrols(since=since, until=until, patrol_type=patrol_type, status=status):
Expand All @@ -431,7 +428,9 @@ async def get_patrol_observations_with_patrol_filter(

observations = await asyncio.gather(*tasks)
observations = pd.concat(observations)
observations["groupby_col"] = observations["patrol_id"]

if include_patrol_details:
observations["groupby_col"] = observations["patrol_id"]

return observations

Expand Down
2 changes: 1 addition & 1 deletion ecoscope/io/earthranger.py
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,7 @@ def get_patrol_observations(self, patrols_df, include_patrol_details=False, **kw
)
)
if len(observation) > 0:
observation["groupby_col"] = patrol["id"]
observations.append(observation)
except Exception as e:
print(
Expand All @@ -904,7 +905,6 @@ def get_patrol_observations(self, patrols_df, include_patrol_details=False, **kw

df = pd.concat(observations)
df = clean_time_cols(df)
df["groupby_col"] = df["patrol_id"]
df = ecoscope.base.Relocations(df)
if include_patrol_details:
return df.set_index("id")
Expand Down

0 comments on commit 0c9fc24

Please sign in to comment.