--TODOs for what needs to be improved:
WITH
trimble_input_data as (
SELECT
EquipmentActivityID
, SensorName
, Value
, Units
, Datetime as dtm
, Geometry -- TODO: link with field geometries & clip, some values are outside of field
, FieldCropYear
, FieldName
, TaskName
, OperationType
FROM login-eko.trimble_coverage_prod.fieldcoverage fc
JOIN login-eko.trimble_latest_prod.equipmentactivity_latest el ON el.id = fc.EquipmentActivityID
WHERE fc.SensorName = 'Calibrated Yield' -- 'Dry Yield' or 'Calibrated Yield' -- TODO: this needs to be parametrized in the streamlit app
AND el.FieldCropYear = 2022 -- TODO: this needs to be parametrized in the streamlit app
AND el.FieldName = 'DJ-106' -- TODO: this needs to be parametrized in the streamlit app
AND el.OperationType = 'Harvesting' -- TODO: this needs to be parametrized in the streamlit app
)
, trimble_param_options as ( -- TODO: this is used to select the relevant options in streamlit to have as defaults for user drop downs
SELECT DISTINCT FieldName, FieldCropYear, OperationType, SensorName
FROM login-eko.trimble_latest_prod.equipmentactivity_latest
JOIN login-eko.trimble_coverage_prod.fieldcoverage ON id = EquipmentActivityID
ORDER BY 1, 2, 3, 4
)
SELECT *
FROM trimble_param_options