WildAid / o-fish-web

Web application for the Officer's Fishery Information Sharing Hub (O-FISH). The web app allows agencies to gain insights from the aggregated information gathered during a routine vessel inspection (submitted via the web app).
Apache License 2.0
31 stars 41 forks source link

Come up with a way to allow for localization of species #506

Open Sheeri opened 2 years ago

Sheeri commented 2 years ago

For Global and Agency Administrators only.

Agencies -> Form Data -> species

Right now this is just a text entry. However, we would like to be able to globally follow a species. As this is a free-form text field, an agency or global administrator can put anything in this field. We want to associate it with a species - for example, Orcinus orca is the Latin name for "Killer Whale", which in French is "Orque".

This will take a lot of work to implement and it would be great if the mobile apps did not have to be changed (I am not sure that's possible, however!).

Sheeri commented 2 years ago

One idea is to store each species as an object instead of a string - right now "species" is an array in the "MenuData" collection, for example:

Current format:

> db.MenuData.find({agency: "Test Agency"}).pretty()
{
    "_id" : ObjectId("xxxxxxxxxxxxxxx"),
    "agency" : "Test Agency",
    "species" : [
        "Atún negro",
        "Marlín Negro",
        "Tiburón Cornuda Gigante",
    ],
       "activity": [ ....

But if they were stored as objects, they could be something like this:

{
    "_id" : ObjectId("xxxxxxxxxxxxxxx"),
    "agency" : "A Spanish Agency",
    "species" : [
        { local: "Atún negro", latin: "Katsuwonus pelamis" },
                 { local: "Marlín Negro", latin: "Makaira indica"},
                 { local: "Tiburón Cornuda Gigante", latin: "Sphyrna mokarran"},
    ],
       "activity": [ ....

{
    "_id" : ObjectId("xxxxxxxxxxxxxxx"),
    "agency" : "An English Agency",
    "species" : [
        { local: "Skipjack Tuna", latin: "Katsuwonus pelamis" },
                 { local: "Black Marlin", latin: "Makaira indica"},
                 { local: "Great hammerhead", latin: "Sphyrna mokarran"},
    ],
       "activity": [ ....

That way, we can cross-reference using MenuData.species.latin, but display using MenuData.species.local.

This would change how the boarding records look, though only slightly. Here's how the species show up in the boarding reports right now:

> db.BoardingReports.findOne()
{
    "_id" : ObjectId("60a5696793e5d06ad86dde58"),
    "agency" : "WildAid",
    "inspection" : {
        "activity" : {
            "name" : "Fishing"
        "actualCatch" : [
            {
                "fish" : "Skipjack Tuna",
                "number" : NumberLong(1),
                "unit" : "lbs",
                "weight" : 1
            },
            {
                "fish" : "Black Marlin",
                "number" : NumberLong(2),
                "unit" : "lbs",
                "weight" : 40
            }
        ],
...
...rest of inspection and other fields...
...
    "date" : ISODate("2021-05-19T19:39:19.383Z")
}

And it could be transformed to

> db.BoardingReports.findOne()
{
    "_id" : ObjectId("60a5696793e5d06ad86dde58"),
    "agency" : "WildAid",
    "inspection" : {
        "activity" : {
            "name" : "Fishing"
        "actualCatch" : [
            {
                "fish" : "Skipjack Tuna",
                "latin" : "Katsuwonus pelamis",
                "number" : NumberLong(1),
                "unit" : "lbs",
                "weight" : 1
            },
            {
                "fish" : "Black Marlin",
                "latin" : "Makaira indica",
                "number" : NumberLong(2),
                "unit" : "lbs",
                "weight" : 40
            }
        ],
...
...rest of inspection and other fields...
...
    "date" : ISODate("2021-05-19T19:39:19.383Z")
}

In this example, the mobile apps would have to be changed to parse the new MenuData format, and store both the fish and the latin name in the BoardingReports collection. And of course anything in the web app that references MenuData.species, or BoardingReports.inspection.actualCatch would need changing.

(one way to do this would be to have a new field in MenuData, called "catch", which can be used by the mobile apps when they're ready, and "species" could be removed when both mobile apps have implemented it.

I'm open to other options of course!