Hi, I am working with @miriam to build out a benchmarking dashboard in farmOS. Here is a very mocked up version with notes, but basically it’s (on the left) a benchmarking table (comparing your soil test values to average values in the db) and on the right there’s a table showing your soil test scores over time by field.
We’re considering creating a kind of ‘empty’ dashboard component that we can put JS into, as JS has many easy to use graphing libraries. However, for the left graph, Drupal would need to create, store and provide (ideally via the API to be most available and most generalizable) average values for each soil test value. For example, let’s talk about soil carbon:
A very simple version of a single lab test log with a soil carbon quantity (not in farmOS structure, but hopefully you get the idea here).
log-lab_test:
quantity:
soil_carbon: 5
Maybe there are 20 of these in the database. So we need to generate an average value across all soil_carbon quantities connected to a lab_test log.
Question: how do we store this resulting average value, and where is the best place to make it available in the api? I don’t see an existing design pattern for this kind of information. There’s a few options:
- Add it to every lab test log as part of
attributes(likeattributes.calculation[0].soil_carbon//.valueor something)`, a… I don’t like this as would be really calculation heavy, but it’s convenient because you don’t have to make a special query to get it. It also could be flexible to many calculations (standard deviation, etc.), and work across all entity types. - Create a completely custom API endpoint as needed
- Create a new top-level entity for data of this type (sorry I may be saying this wrong… but read on hopefully it makes sense)… for example, imagine if in the api there was also a
log--lab_test_calculationsor something, which then contained this and any other calculations (for example, standard deviation) that you may want to apply to lab test logs and their associated quantities. This is nice because it generalizes to any other entities (assets, logs, etc.) and any other calculations you’d want to apply to a log. It would not handle calculations across different entity types.
Maybe these are all bad options, not sure. Would love any ideas or feedback on this.

