I know we’ve discussed this & similar issues before, but I couldn’t find anything that covered all the bases, so I’m starting this post
I’m starting to work on a use case where I want to keep track of different activities (simple metadata like timestamp, notes, and photos) that are associated with plant assets. Some example activities are training, pruning, mowing and harvests.
Naturally, it makes sense to use Activity and Harvest logs that reference the plant asset(s) to model these records. This provides the metadata values & asset references I need. But it doesn’t provide a way to specify which “activity type” the activity log represents. This is important so that I can later query which “activities” have been completed for the asset.
I see a few options for representing this:
- Create a new log type for each activity. This would work, but seems unnecessary since all of my activities need the same metadata (with the exception of the “harvest” activity, which already has its own log type).
-
Create log categories for each activity type (
training
,pruning
andmowing
log categories). This has been recommended before and is actually my current approach for a similar use case. This works because it’s possible to query activity logs in thetraining
category that reference a specific asset. But this doesn’t seem like the correct solution since activity logs would be the ONLY log type assigned to these categories. In other words, it seems like log categories should only be used when logs of multiple types might represent the same “category”. A good example of this is the “Tillage” category that was created here: https://www.drupal.org/project/farm/issues/2965739 - Create a custom Plan type to track which activities have been completed for the plant assets. This could be another option, where a custom Plan type could have specific fields for “Training logs”, “Pruning logs”, etc. The limitation with this approach is that it becomes much more challenging (currently impossible in 1.x) to create these records via the API, such as in Field Kit. Even with the ability to update a Plan & its fields via the API, this means the 3rd party has the added requirement of updating the Plan via the API. This all seems unnecessary to simply model “activity types” on assets.
I’m curious about another option: Creating an optional “type” field on Activity logs that references pre-defined “activity types” configured in the farmOS instance. For farmOS 2.x it would make sense to model these “Activity types” as config entities. This would make it possible to query all activity logs that reference an asset, but then limit results by specifying an activity.type
value.
Adding such a field to activity logs would make it possible to model “activity types” without requiring custom code/modules to provide another log or plant type. You could argue this is already possible without custom code by using log categories, but this seems like a better solution IMO. This is similar to the method
field on Input logs too, although that is only a simple text field right now.
Thoughts?