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

Instances of unit displays

Expand
titleList of <Unit /> (59 instances in 29 files)

(This is not 100 percent accurate)

Path
&
file (29)
(/packages/webapp/src/components)

Number of unique <Unit /> (59)

&

Views

Type
(pre-populated / user input)

Operation
(Create/Read/Edit)

automatic conversion

Note

1

crop/:cropId(?)add_management_plan/bed_method

file:
/Crop/BedPlan/PureBedForm.jsx

4

user input

create

NO

🕷️ Currently, raw data(what the user has inputted) is stored in the DB.

  • After switching unit system(User’s farm unit system preference), data conversion does not happen.

2

/tasks/:taskId?/read_only

file:
/Crop/BedPlan/PurePlanGuidanceForm.jsx

3

-

read

-

3

/crop/:cropId?/add_management_plan/broadcast_method

file:
/Crop/BroadcastPlan/PureBroadcastForm.jsx

3

  • area used & Estimated seed required: pre-populated

  • user input

create

NO

  • “estimated seed required is calculated by inputting “seeding rate”, but it does not take the unit into account.

(warning) The location size does not need a unit?

4

/crop/:cropId?/management_plan/:planId?/edit

file:
/Crop/ManagementDetail/EditManagementPlanDetail.jsx

1

user input

edit

NO

5

/crop/:cropId?/management_plan/:planId?/details

file:
/Crop/ManagementDetail/ManagementPlanDetail.jsx

1

-

read

-

6

/crop/:cropId?/add_management_plan/planted_already

file:
/Crop/PlantedAlready/index.jsx

2

user input

create

NO

7

/crop/:cropId?/add_management_plan/container_method

file:
/Crop/PlantInContainer/PureContainerForm.jsx

5 (4)

These should be combined ⬇️

user input

create

NO

  1. # of plants → “1”. Estimated seed required input is displayed.
    # of plants → “10”
    the input disappears. 🕷️?

  2. (warning) after switching a unit for the calculated input, the calculation does not change.

    Screen Recording 2023-02-27 at 8.56.16 PM.mov


8

/crop/:cropId?/add_management_plan/plant_date

condition:
already_in_ground && is_wild && !needs_transplant

file:
/Crop/PlantingDate/NextHarvest.jsx

1

user input

create

NO

9

/crop/:cropId?/add_management_plan/plant_date

condition:
!(already_in_ground && is_wild && !needs_transplant)

file:
/Crop/PlantingDate/PurePlantingDate.jsx

1

user input

create

NO

10

/crop/:cropId?/add_management_plan/final_planting_method

condition:

is_planting_method_known === false && showIsPlantingMethodKnown && isFinalPlantingMethod

file:
/Crop/PlantingMethod/PureManagementPlanPlantingMethod.jsx

1

user input

create

NO

11

/crop/:cropId?/add_management_plan/row_method

the component is used for #2

file:
/Crop/RowMethod/PureRowForm.jsx

5

user input

create

NO

🕷️ Estimated seed 20lb (not “stored as” unit) was saved in the DB

12

/finances/estimated_revenue/plan/:planId

file:
/Finances/UpdateEstimatedCropRevenue/index.jsx

2

user input

create/edit?

NO

(warning) the first unit should be $/kg or $/mt? “Estimated annual revenue” does not change by changing units.

13

/add_sale

/edit_sale

file:
/Inputs/CropVarietySale/index.jsx

2

user input

create

edit

-

(warning) the style for the quantity input is different from others

  • <Unit /> does not need to be used for $…

14

/create_location/ceremonial_area etc.

file:
/LocationDetailLayout/AreaDetails/AreaDetails.jsx

2

pre-populated

create

NO

15

/create_location/buffer_zone

/buffer_zone/:bufferId?/details

file:
/LocationDetailLayout/LineDetails/BufferZone/index.jsx

2

pre-populated

create

read

edit

NO

16

/create_location/fence

file:
/LocationDetailLayout/LineDetails/Fence/index.jsx

1

pre-populated

create

NO

17

/create_location/watercourse

/watercourse/84cb7da8-abe9-11ed-8b70-e66db4bef551/details

file:
/LocationDetailLayout/LineDetails/Watercourse/index.jsx

4

pre-populated / user input

create

read

edit

NO

18

/sensor/:sensorId?/details

file:
/LocationDetailLayout/PointDetails/Sensor/index.jsx

1

-

read

-

🕷️ 0.87cm???

After adding sensors with “150cm” and “200cm”, they were shown as “1.5m” and “2cm”.

19

/create_location/water_valve

file:
/LocationDetailLayout/PointDetails/WaterValve/index.jsx

1

user input

create

NO

20

/map
(location - watercourse)

file:
/Map/LineMapBoxes/index.jsx

2

pre-populated

create

-

21

/add_task/task_details

file:
/Modals/WaterUsageCalculatorModal/index.jsx

6

user input

create

YES

22

/sensor/:sensorId?/edit

file:
/Sensor/EditSensor.jsx

1

pre-populated (reading the data in DB)

edit

NO

22

/add_task/task_details

file:
/Task/AddProduct/index.jsx

1

user input

create

NO

23

/add_task/task_details

file:
/Task/CleaningTask/index.jsx

1

user input

create

NO

24

/add_task/task_details

file:
/Task/HarvestingTask/index.jsx

1

user input ↔︎ disabled by checking “harvest everything”

create

NO

25

/tasks/:taskId?/read_only

file:
/Task/HarvestingTask/ReadOnly.jsx

2

-

read

-

26

/add_task/task_details

file:
/Task/PureIrrigationTask/index.jsx

1

Screen Recording 2023-02-10 at 5.14.32 PM.mov

user input

create

YES

🕷️ When I input “2 gal” in the estimated water usage input, “2 gal” was saved in the DB.

27

/tasks/:taskId?/harvest_uses

file:
/Task/TaskComplete/HarvestComplete/HarvestUses.jsx

1

user input

create

NO

(warning) when changing unit, “Amount to allocate” does not change. Should it?

28

/tasks/:taskId?/complete_harvest_quantity

file:
/Task/TaskComplete/HarvestComplete/Quantity.jsx

1

user input

create

NO

...

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

...