Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Author: Sayaka Ono

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…)

(warning) Question

  • range error for the inputted value


    The maximum number that can be accepted changes depending on the selected unit, but the error message does not change. What is it supposed to be? (currently the error message is always 0-1000000000 for the input in the screenshot)

    • ac: 4046860338724.812

    • ft2: 92903129.90644656

    • m2: 1000000000

    • ha: 10000000000000 (stored as)

(I misunderstood this part. The error is shown against the hidden value. How this works is that the max value for the visible input is converted to “stored as” value to match the unit with that of the hidden value, and the hidden value is validated.)

TODO

  • ask for answers to all questions and make the requirements crystal clear → create a document(how each Unit input works, how the data is stored in the DB, etc) that can also be used as a reference when testing

  • update the style?

    Jira Legacy
    serverSystem JIRA
    serverId815f41e5-e5fb-3402-8587-82eccc3ffab0
    keyLF-2910
    → NO

  • save data in an apples-to-apples manner

  • show data correctly on the frontend (should be able to support automatic conversion in the future)

  • write tests

  • figure out which data needs to be backfilled and how → write a script.

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

    https://docs.google.com/spreadsheets/d/1XZ-Pgy4xAqYlLCQUeYb3a2pZAknimCRlAwlVdP8xZT4/edit#gid=391799990
    (warning) should we correct data in production/beta or both? Do we need to investigate when we started saving wrong data?

  • we need to deploy APIs & app after backfilling is complete. Does anyone know how?

  • fix related bugs

...