[Racket] Ferti hydroponic nutrient solver, redux.
Fertilizers should not report nutrients which they don't contain...
views.rkt
@@ -245,13 +245,14 @@
245
245
246
246
(define (show-fertilizer-page fp)
247
247
(define title (fertilizer-product-name fp))
248
Added:
(define nutrient-values (fertilizer-product-values fp))
248
249
(define table
249
250
`(table ((class "table"))
250
251
(thead (tr (th "Nutriment") (th ((class "text-end")) "Apport (mg/L)")))
251
Removed:
(tbody ,@(for/list ([n (get-nutrients)])
252
Removed:
(define nutrient-value (hash-ref (fertilizer-product-values fp) n 0))
253
Removed:
`(tr (td ,(nutrient-french-name n))
254
Removed:
(td ((class "text-end font-monospace")) ,(round 2 nutrient-value)))))))
252
Added:
(tbody ,@(for/list ([(nutrient quantity) (in-hash nutrient-values)]
253
Added:
#:when (not (zero? quantity)))
254
Added:
`(tr (td ,(nutrient-french-name nutrient))
255
Added:
(td ((class "text-end font-monospace")) ,(round 2 quantity)))))))
255
256
256
257
(page-template title
257
258
`((h1 ((class "display-1 mb-3")) ,title)