Skip to content

Conversation

@gbabineau
Copy link

This PR addresses #25 which I created. I needed to get the first observation of a taxa on the date specified for get_historic_observations. This functionality is provided in the eBird API but was not made available in this python wrapper.

I attempted to follow the coding standards. The changes are simple.

I also tested that the existing functionality still works - either as default, or by passing the parameter it had been defaulting to.

I hope this is useful! I appreciate the work to put this wrapper together and am glad to contribute back.

# demonstrate that existing functionality is still supported when no rank is supplied
# It should print a time when the Clapper Rail was seen at the end of the day
observations = get_historic_observations(
    token=ebird_api_key, area='US-VA-003', date=date(2021, 4, 9), category="species"
)
clapper_rail_obs = next((obs for obs in observations if obs.get('comName') == 'Clapper Rail'), None)
print(clapper_rail_obs.get('obsDt'))

# demonstrate that new functionality is supported when rank=="create
# It should print a time when the Clapper Rail was seen at the beginning of the day
observations = get_historic_observations(
    token=ebird_api_key, area='US-VA-003', date=date(2021, 4, 9), category="species", rank="create"
)
clapper_rail_obs = next(
    (obs for obs in observations if obs.get("comName") == "Clapper Rail"), None
)
print(clapper_rail_obs.get("obsDt"))

# demonstrate that new functionality is supported when rank=="mrec"
# It should print a time when the Clapper Rail was seen at the end of the day
observations = get_historic_observations(
    token=ebird_api_key, area='US-VA-003', date=date(2021, 4, 9), category="species", rank="mrec"
)
clapper_rail_obs = next(
    (obs for obs in observations if obs.get("comName") == "Clapper Rail"), None
)
print(clapper_rail_obs.get("obsDt"))

and the results are correct, showing evening, morning, evening.

2021-04-09 19:15
2021-04-09 07:08
2021-04-09 19:15

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant