dronefly-garden / dronefly

Red Discord Bot V3 cogs for naturalists.
Other
16 stars 3 forks source link

ebird: Checklist summary #56

Open 7-ate-9 opened 4 years ago

7-ate-9 commented 4 years ago

Similar to iNat observation but for eBird checklists

7-ate-9 commented 4 years ago

It would be nice to show something about what species are on the list, but lists can have 50-100 species (although most will have 5-30) so I'm not sure what the best way to do that would be. Some possibilities:

dfloer commented 4 years ago

Are you envisioning the command taking a checklist ID of the form "S59832077" (a checklist of mine from a couple months ago), or would there also need to be a way to discover the checklist (and IDs) too?

synrg commented 4 years ago

Yes, we'd need a way to discover those, but by chaining from API calls used in other commands, we can follow the linkage from the records returned by, e.g. the ebird hybrids command.

I determined experimentally that the historic observations by date API call will give you the checklist IDs when you pass detail=full in the call:

https://documenter.getpostman.com/view/664302/S1ENwy59?version=latest#2d8c6ee8-c435-4e91-9f66-6d3eeb09edd2

So if you take the existing ebird hybrids command, for which both the regionCode and the date of recently observed observations for that region are known, that's all we need to do this call, e.g.

https://api.ebird.org/v2/data/obs/US-MA/historic/2020/1/16?cat=hybrid&detail=full

[
    {
        "checklistId": "CL23379",
        "comName": "Mallard x American Black Duck (hybrid)",
        "countryCode": "US",
        "countryName": "United States",
        "firstName": "chris",
        "hasComments": false,
        "hasRichMedia": false,
        "howMany": 1,
        "lastName": "roberts",
        "lat": 42.0332033,
        "lng": -72.5975322,
        "locId": "L330361",
        "locName": "Fannie Stebbins Wildlife Refuge",
        "locationPrivate": false,
        "obsDt": "2020-01-16 12:00",
        "obsId": "OBS852443863",
        "obsReviewed": false,
        "obsValid": true,
        "presenceNoted": false,
        "sciName": "Anas platyrhynchos x rubripes",
        "speciesCode": "x00004",
        "subId": "S63484808",
        "subnational1Code": "US-MA",
        "subnational1Name": "Massachusetts",
        "subnational2Code": "US-MA-013",
        "subnational2Name": "Hampden",
        "userDisplayName": "chris roberts"
    }
]

Just iterate over each unique date matched by the existing hybrids API call & that will give you all the checklistId's you need to get at least a first subcommand to make use of this enhancement (e.g. similar to inat last subcommands which link from other recent commands to a subdisplay).

Though I think I may be conflating this issue in my mind with a similar issue for the hybrids command to simply link to the checklist. I'll dig up the ID for that ...

synrg commented 4 years ago

Yeah, the related issue I mixed this up with is this one: https://github.com/synrg/dronefly/issues/61 so ... doing something like I proposed above (hooking up the output of hybrids to retrieve the checklist details for each record matched) should be the subject of a whole separate issue.

So back to your original question, @dfloer, as to my statement "similar to iNat observation", the way that works is just by sharing the URL of the observation to a channel (though it's also possible just to give the command the ID#, if you've cut-and-pasted that from a display). Users already are comfortable with pasting eBird checklist links in Discord, so at least for a first version of this, no lookup of the checklist ID is needed. With the similar iNat support, we have an on handler that looks for new messages which just Regex matches the link & produces the observation summary from that. See inat autoobs. If we had something similar for eBird, checklists would probably be the best place to start, since that's mostly the kind of link that people are currently sharing already.

synrg commented 4 years ago

7-ate-9 wrote:

It would be nice to show something about what species are on the list, but lists can have 50-100 species (although most will have 5-30) so I'm not sure what the best way to do that would be.

Some sort of pagination seems reasonable. That could be provided by reaction buttons that update the emitted embed to show additional pages. If the list of species could be sorted so that "interesting" species are put first, then it makes it less likely any further interaction would be needed, giving people what they most likely want to see right away.