From b4b113796455b85389df1c826f6e7ec93e804001 Mon Sep 17 00:00:00 2001 From: Marius Peter Date: Mon, 24 Nov 2025 15:44:58 +0100 Subject: Add French name to nutrient model. --- models/crop-requirement.rkt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'models/crop-requirement.rkt') 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) -- cgit v1.2.3