From a26fa8aa89c09b49284cbb5d674399d659f98c1b Mon Sep 17 00:00:00 2001 From: Marius Peter Date: Wed, 3 Dec 2025 21:17:13 +0100 Subject: Fertilizers should not report nutrients which they don't contain... --- views.rkt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'views.rkt') diff --git a/views.rkt b/views.rkt index ebe1aad..130b98d 100644 --- a/views.rkt +++ b/views.rkt @@ -245,13 +245,14 @@ (define (show-fertilizer-page fp) (define title (fertilizer-product-name fp)) + (define nutrient-values (fertilizer-product-values fp)) (define table `(table ((class "table")) (thead (tr (th "Nutriment") (th ((class "text-end")) "Apport (mg/L)"))) - (tbody ,@(for/list ([n (get-nutrients)]) - (define nutrient-value (hash-ref (fertilizer-product-values fp) n 0)) - `(tr (td ,(nutrient-french-name n)) - (td ((class "text-end font-monospace")) ,(round 2 nutrient-value))))))) + (tbody ,@(for/list ([(nutrient quantity) (in-hash nutrient-values)] + #:when (not (zero? quantity))) + `(tr (td ,(nutrient-french-name nutrient)) + (td ((class "text-end font-monospace")) ,(round 2 quantity))))))) (page-template title `((h1 ((class "display-1 mb-3")) ,title) -- cgit v1.2.3