Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents
minLevel1
maxLevel7

...

When

When the value is(was) pre-populated by the system

When a value is NOT pre-populated by the system or was user created

creating

the https://lite-farm.atlassian.net/wiki/spaces/LITEFARM/pages/658309153/Unit+displays#Default-display-guidance should determine the value / unit combination

the user set unit preference should be used

(warning) What is the “user set unit preference”? Is it a record-to-record unit(a record has not been created on a creation view) or user’s farm unit system preference (metric/imperial)?

read-only

the https://lite-farm.atlassian.net/wiki/spaces/LITEFARM/pages/658309153/Unit+displays#Default-display-guidance should be used
(warning) Once pre-populated value is modified, is it considered as a “user created” value? Currently, even if I change the unit to “ft2” and save, “ac” is still shown. Is it a bug?

the user set unit preference should be used





editing

the https://lite-farm.atlassian.net/wiki/spaces/LITEFARM/pages/658309153/Unit+displays#Default-display-guidance should be used

the user set unit preference should be used

  • automatic conversion - we will go with easier solution.
    (warning)We do not need to see automatic conversion at all for now? (how about the total area?)

...

  1. User’s farm unit system preference is “imperial”. The user created a barn and the total area was 50,000 acres. He switched the unit system to “metric”. (the record-to-record unit and the unit system setting don’t match)
    -> The total area should be displayed in (warning) ha as determined by the default display guidance. (not record-to-record unit?)

    Jira Legacy
    serverSystem JIRA
    serverId815f41e5-e5fb-3402-8587-82eccc3ffab0
    keyLF-2880

  2. User’s farm unit system preference is “imperial”. The user created a crop plan with planting depth 3 inches.
    -> The depth should be stored in (warning) XXX.
    (warning) “depth” is not in the https://lite-farm.atlassian.net/wiki/spaces/LITEFARM/pages/658309153/Unit+displays#Default-display-guidance. Is there a guidance for depth and spacing?

...

proposed approach

alternative approach

backfill data

find wrong data and write a script

database

no change required

APIs

  • [POST] convert received values to “stored as” values for each endpoint and store (create a helper or middleware)

  • [GET] convert saved values to “display” values before sending to a client (create a helper or middleware)

  • add tests for each endpoint

no change required

frontend

  • remove logic from the Unit component (make it a presentation component)

  • create a hook to handle logic, and add comments to make it clear what the code does (this still needs to calculate what the values would be when stored in the database)

  • remove logic from the Unit component (make it a presentation component)

  • create a hook to handle logic, and add comments to make it clear what the code does (this includes data conversion when submitting or showing data)

  • write tests for each unit input

auto conversion
(optional)

DB: need migration (auto conversion property in the userFarm table)
(UI: modify the user setting view to set “auto conversion”)

backend: update the helper or middleware to take user setting into account

frontend: update the hook to take user setting into account

pros

  • some logic can be removed from the frontend

  • the logic is in one place and could avoid small errors for adding lines all over the files

  • no need to test APIs

cons

  • frontend still needs to take care of some calculations

  • need to update many APIs and their tests

  • QA needs to test APIs + UI

  • should be careful not to make the same mistakes (no more rework…)

...