diff options
| -rw-r--r-- | views.rkt | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -242,15 +242,15 @@ (define (show-fertilizer-page fp) (define product-name (fertilizer-product-name fp)) (define brand-name (fertilizer-brand-name fp)) - (define nutrient-values (fertilizer-product-values fp)) + (define positive-nutrient-values (hash-filter-values (fertilizer-product-values fp) positive?)) + (define sorted-nutrient-values (sort (hash->list positive-nutrient-values) > #:key cdr)) (define table `(table ((class "table")) (thead (tr (th "Nutriment") (th ((class "text-end")) "Apport (mg/L)"))) - (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))))))) - + (tbody ,@(for/list ([nv-pair sorted-nutrient-values]) + (match-define (cons n v) nv-pair) + `(tr (td ,(nutrient-french-name n)) + (td ((class "text-end font-monospace")) ,(round 2 v))))))) (page-template product-name `((h1 ((class "display-1 mb-3")) ,(or brand-name "Intrant générique")) (h5 ((class "display-5 mb-3")) ,product-name) |