Use taxonomy for quantity labels

Another idea that has come up while thinking about quantities with various people. The label is another common point of complexity/confusion and wondering if it could be improved by using a taxonomy instead. From our docs: “A Quantity may have a label assigned to it. This helps to distinguish multiple Quantities of the same measure within a Log.”: Quantities | farmOS

There are a few general reasons a taxonomy could be an improvement for the quantity label:

  • One step towards consistent quantity labels, eg: prevent “gallons” vs “gallon” by referencing a common term
  • Ability to see a list of all unique quantity labels (currently this is very hard to curate in the UI on a farmOS instance with 1000s of quantities)
  • One step towards “machine readable” label, maybe a solution to what @Symbioquine described here: The fields in a quantity entity - #2 by Symbioquine (A term is not necessarily required for this, but may be an easy solution to provide some type of custom “ID” field for quantity labels if the term ID is not sufficient by itself)
  • Potential ability for a quantity label term to define the default measure or units associated with it. This could be single or multi-value if a given label is used in different contexts.

Another observation I had relates to the new quantity material and test quantity types and how the label it is (or isn’t) used to distinguish multiple quantities on a log. These types allow quantities to be distinguished by a material_type or test_method taxonomy term reference in addition to the optional label.

  • In practice I see that most material quantities do not use the label.
  • The test quantity convention specifies they “MUST include a “Label” to represent the soil indicator that is being measured.” - however I wonder if this soil indicator could actually be specified by the test_method term instead, and not require the element be a label? If this were the case…
  • Could quantities be refactored to not need separate material and test quantity types, and instead let the single quantity label field reference a single term from any of these taxonomies: quantity label (better naming?), material type, or test method?

I like the idea of making label into a taxonomy. This would be a breaking change, of course, so it would have to happen in farmOS 3.x. We did something similar with the “Laboratory” field on Lab Test logs, so we can use that migration code for reference.

I’m not sure I’ve fully wrapped my head around this idea yet. Something about a field referencing terms from multiple taxonomy bothers me. But that might just be habit of thinking. Is there a risk of ambiguity? It’s easy to understand the “meaning” of a field that references terms in a single vocabulary because it is very explicit: “The material type of this quantity is Compost”.

The field would need to allow multiple values. I’m trying to imagine a single field that references a material term AND a quantity label term AND a test method term. The vocabulary that each belongs to can be used to imply its meaning, but something feels wrong about it IMO.