Proposal: Remove "Status" field from Assets and Plans

@paul121 and I had a chat about this a few weeks ago and I want to capture it here for public consideration.

Proposal: Remove the status field from assets and plans and replace it with a boolean archived field.

This would change the data model so that assets and plans are either “archived” or “not archived”, but do not have an explicit “status”.

The benefit of doing this is it separates the concept of “archived”, which in practice is simply a mechanism for hiding/filtering out assets/plans in the UI/API.

This would allow other modules to add their own “Status” field(s) to assets/plans, which can be more targeted to use-case-specific workflows.

For example, a custom plan type may want to provide its own set of statuses, instead of the default “Active” status.

Worth noting, this would actually be a bit more like the original farmOS v1 data model, which changed in v2. In farmOS 1.x, assets had a property called archived which was either 0, which indicated that the asset was active, or a timestamp that recorded when the asset was archived. In farmOS 2.x, these were split into two separate fields:

  • status - The status of the asset (either active or archived).
  • archived - The timestamp when the asset was archived. This will be empty if the asset is active.

I propose we simplify things by removing the current status field and convert the archived field to a boolean on both assets and plans. I don’t think there is a need to record the timestamp when the record was archived, because this is captured in revisions now (as of farmOS v2).

Logs would remain unchanged under this proposal.

This is my primary motivation for proposing this. I’ve started working on a custom plan type that provides its own set of statuses, and does not include active as an option (because everything other than archived is technically considered “active”).

I ran into some issues with current code that assumes active will be a valid status.

IMO farmOS should support the ability to have plans with statuses that are more nuanced than just “Active”, so it got me thinking more broadly about what “Status” currently means and what it’s used for.

I opened a pull request that attempts to work around the issues I encountered: Allow plans without active status in farm_plan View by mstenta · Pull Request #978 · farmOS/farmOS · GitHub

This is not a perfect solution, but is worth considering if we don’t have the capacity (or consensus) to make this larger proposed change to the data model.

I agree with your solution!

1 Like