dronefly-garden / dronefly

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

taxon: include a list of child taxa sorted by # of observations #42

Open synrg opened 5 years ago

synrg commented 5 years ago

Related to https://github.com/synrg/quaggagriff/issues/41 it would be nice to expand on that display and also include children of a taxon, up to some reasonable limit, with the same sort of "and # more" collapsing that that the map command has for the overflow.

So, something like:

[p]taxon leptoglossus ->

Genus Leptoglossus is a genus with 16260 observations in:

Animalia > Arthropoda > Hexapoda > Insecta > Pterygota > Hemiptera > Heteroptera > Pentatomomorpha > Coreoidea > Coreidae > Coreinae > Tribe Anisoscelini

with these most commonly observed species:

L. occidentalis (6441), L. phyloppus (2974), L. oppositus (1272), L. zonatus (1099), L. clypealis (722), L. gonagra (226), L. fulvicornis (149), L. corculus (48), L. lineosus (35), L. concolor (23), L. fasciolatus (17), L. brevirostris (12), and 50 more species with 9 or fewer observations.

The constraints on how many child taxa can be listed are:

Note: the mockup above is already approaching 1000 characters without links to all of the listed taxa or their maps included, so this may indicate that it's a bad idea to add so many links. Consider leaving off the more "expensive" links to maps and/or the links to the child taxa themselves so we can include more child taxa within the constraints shown above.

It would be helpful to also provide another command (perhaps [p]inat next, aliased as [p]next or [p]n) and/or reaction button menu to access the "inaccessible" children in the ellipsis "and 50 more". But that should be the topic of new issue.

synrg commented 5 years ago

See also https://github.com/synrg/quaggagriff/issues/34 to support the shorthand "L. occidentalis", etc. for a specified list of taxa.

synrg commented 5 years ago

A modifier with might be nice to support in the query to control what gets enumerated, where the default is to enumerate immediate children, but with could be used to enumerate the specified rank instead, e.g. [p]taxon Anisoscelini to start at the tribe and enumerate its top genera, but [p]taxon Anisoscelini with sp would enumerate the species within the tribe instead. This, of course, should have its own issue if we pursue it.

synrg commented 3 months ago

The preferred preposition now for listing taxa at a specific rank would be per, just like in the ,life command, e.g. [p]t Anisoscelini per sp to enumerate all species as a flat list, and should accept all of the same values as ,life does (main, any, leaf).

We should add per child as another value: listing the whole tree has performance implications, as the whole tree may need to be traversed with additional API hits to collect all of the descendants, whereas no additional API calls are needed to enumerate all of the direct children of a taxon that has been already fetched by /v1/taxa/{id} endpoint.

The per child feature can be developed with ,life command first. Then to make all of this work with ,taxon, we could support it as a whole new taxon menu that looks and feels just like life only is populated from descendent taxa of the specified taxon.

When this new interaction is started, the "social buttons" will no longer be available. If a user wants to show the children for an existing taxon display that they or someone else displayed, reply-chaining can be used to start the interaction, e.g.

,t anisoscelini => displays the usual Taxon display with just this taxon ,t per child (Reply to previous display) => starts the per child interaction with a menu just like the ,life command, but populated from the descendents of the taxon, whether or not they have observations

If the options are combined, i.e. ,t Anisoscelini by me per species, then it should just invoke the ,life command instead.

synrg commented 3 months ago

As of 38bc513f5c64574ec4d48b20bc4a10da2faf47c9 with latest dronefly-discord and dronefly-core, per child is supported for ,life command, but not yet in conjunction with sort by obs. Also, the ,taxon command doesn't yet support per child. That will take a fair amount more work.

synrg commented 3 months ago

With #118 now closed, it could be argued that ,t list provides all of this info in a more convenient way because you can paginate through it. I'll leave this open, though, because it's still a nice idea to provide a small summary of the most popular child taxa in the main taxon display, something that comes at the cost of zero additional API calls which is very appealing.

In the meantime, you can now display a list of child taxa (i.e. only direct children, not grandchildren and below) sorted by # of observations for an already shown taxon display either with ,t list [query] sort by obs or with ,t [query] (or any other command that outputs a single taxon) then reply-chain ,t list sort by obs to the taxon displayed by the bot.