diff options
Diffstat (limited to 'models/nutrient-value.rkt')
| -rw-r--r-- | models/nutrient-value.rkt | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/models/nutrient-value.rkt b/models/nutrient-value.rkt index 08bcfad..9653c7f 100644 --- a/models/nutrient-value.rkt +++ b/models/nutrient-value.rkt @@ -5,12 +5,15 @@ nutrient-value-hash/c (contract-out [insert-nutrient-values (-> connection? db-id? nutrient-value-hash/c (listof (cons/c symbol? any/c)))] + [get-sorted-nutrient-values + (-> nutrient-value-hash/c (listof (cons/c nutrient? nutrient-value?)))] [update-nutrient-values! (-> connection? db-id? nutrient-value-hash/c void?)] [residuals->nutrient-value-hash (-> (listof residual-vector/c) nutrient-value-hash/c)])) (require db sql + racket/hash "nutrient.rkt" "utils.rkt") @@ -34,6 +37,9 @@ #:from (TableExpr:AST ,(make-values*-table-expr-ast nv-rows))))) (simple-result-info result)) +(define (get-sorted-nutrient-values nv) + (sort (hash->list (hash-filter-values nv positive?)) > #:key cdr)) + (define (update-nutrient-values! conn nvs-id nutrient-values) (for ([(n v) (in-hash nutrient-values)]) (query-exec conn |