diff options
Diffstat (limited to 'models/nutrient-value.rkt')
| -rw-r--r-- | models/nutrient-value.rkt | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/models/nutrient-value.rkt b/models/nutrient-value.rkt index b5798db..08bcfad 100644 --- a/models/nutrient-value.rkt +++ b/models/nutrient-value.rkt @@ -5,6 +5,7 @@ nutrient-value-hash/c (contract-out [insert-nutrient-values (-> connection? db-id? nutrient-value-hash/c (listof (cons/c symbol? any/c)))] + [update-nutrient-values! (-> connection? db-id? nutrient-value-hash/c void?)] [residuals->nutrient-value-hash (-> (listof residual-vector/c) nutrient-value-hash/c)])) @@ -33,6 +34,13 @@ #:from (TableExpr:AST ,(make-values*-table-expr-ast nv-rows))))) (simple-result-info result)) +(define (update-nutrient-values! conn nvs-id nutrient-values) + (for ([(n v) (in-hash nutrient-values)]) + (query-exec conn + (update nutrient_values + #:set [value_ppm ,v] + #:where (and (= value_set_id ,nvs-id) (= nutrient_id ,(nutrient-id n))))))) + (define (residuals->nutrient-value-hash residuals) (for/hash ([r (in-list residuals)]) (match-define (vector n-id n-canonical-name n-french-name n-formula value-ppm) r) |