diff options
| author | Marius Peter <dev@marius-peter.com> | 2025-11-24 15:44:58 +0100 |
|---|---|---|
| committer | Marius Peter <dev@marius-peter.com> | 2025-11-24 15:44:58 +0100 |
| commit | b4b113796455b85389df1c826f6e7ec93e804001 (patch) | |
| tree | da3f143888cf883dd1f109962c84cf58a74e523f /models/crop-requirement.rkt | |
| parent | 507844a30cbbdaf166a2fd56c9a6e4985c7d7c97 (diff) | |
Add French name to nutrient model.
Diffstat (limited to 'models/crop-requirement.rkt')
| -rw-r--r-- | models/crop-requirement.rkt | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/models/crop-requirement.rkt b/models/crop-requirement.rkt index fb14777..c0eb753 100644 --- a/models/crop-requirement.rkt +++ b/models/crop-requirement.rkt @@ -80,6 +80,7 @@ cr.crop_id n.id n.canonical_name + n.french_name n.formula nv.value_ppm #:from (TableExpr:AST ,joined) @@ -98,7 +99,6 @@ [profile (scalar-expr-qq (= cr.profile ,profile))] [crop-id (scalar-expr-qq (= cr.crop_id ,crop-id))] [else (error 'get-crop-requirement "one of #:id, #:profile or #:crop-id must be provided")])) - (define grouped-rows (query-rows (current-conn) (select cr.id @@ -106,27 +106,28 @@ cr.crop_id n.id n.canonical_name + n.french_name n.formula nv.value_ppm #:from (TableExpr:AST ,joined) #:where (ScalarExpr:AST ,where)) #:group '#(0 1 2))) - (match grouped-rows ['() #f] [(list row) (grouped-row->crop-requirement row)] [many (error 'get-crop-requirement "expected 1 crop requirement, got ~a" (length many))])) (define (get-crop-requirement-values crop-requirement) - (for/hash ([(nutrient-id name formula value_ppm) + (for/hash ([(nutrient-id canonical-name french-name formula value_ppm) (in-query (current-conn) (select n.id n.canonical_name + n.french_name n.formula nv.value_ppm #:from (TableExpr:AST ,joined) #:where (= cr.id ,(crop-requirement-id crop-requirement))))]) - (values (nutrient nutrient-id name formula) value_ppm))) + (values (nutrient nutrient-id canonical-name french-name formula) value_ppm))) (define (get-crop-requirement-value crop-requirement nutrient) (query-maybe-value (current-conn) |