summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarius Peter <dev@marius-peter.com>2025-12-03 21:17:13 +0100
committerMarius Peter <dev@marius-peter.com>2025-12-03 21:17:13 +0100
commita26fa8aa89c09b49284cbb5d674399d659f98c1b (patch)
tree7eac81a7ff4b8742698e9880746e2cc90b2db762
parentcafc59e5930997934fbbb6b5f6e8024ed33fc1f9 (diff)
Fertilizers should not report nutrients which they don't contain...
-rw-r--r--views.rkt9
1 files changed, 5 insertions, 4 deletions
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)
Copyright 2019--2026 Marius PETER