HackYourFuture-CPH / FP-class11

Class11 Final Project - A collaboration between HYF and Seasony
MIT License
5 stars 8 forks source link

Endpoint to populate Status Box #142

Closed dpfernandes closed 4 years ago

dpfernandes commented 4 years ago

We need an endpoint that populates this Status Box

Screenshot 2020-04-12 at 13 36 44Screenshot 2020-04-12 at 13 36 36

All the operations have to assume that they get BATCH_ID as a parameter.

Status - need to check if all the sensors provide a value within the limits. Please follow these rules:

  1. If the values from the sensors are between the max and the min it shows Okay .
  2. If the value of more than one sensor shows values higher or lower than the max or min then the status should show CHECK SENSORS .
  3. If it’s just one sensor that shows values higher or lower than the max or min then status should show CHECK PH or CHECK WATER LEVEL and so on.

Days left to harvest - Calculate the harvest start date using duration value on the crop_stages table and seeding_date value on batches table and return the number of days.

Days left to end the batch - Calculate the sum of all the durations of that specific batch using duration values of all the stages (crop_stages table) and seeding_date value on batches table, and return the number of days.

Current stage - Using the seeding_date on the Batch Table and the duration values on Crop_stages find validate in which stage should the batch be and return the stage.

Production Start Date - Seeding date

Production End Date - From the seeding date add the number of days calculated on Days left to end the project

If any of these values are not available it should return a value NULL for that specific value.