summaryrefslogtreecommitdiff
path: root/models/crop-rotation.rkt
diff options
context:
space:
mode:
Diffstat (limited to 'models/crop-rotation.rkt')
-rw-r--r--models/crop-rotation.rkt22
1 files changed, 10 insertions, 12 deletions
diff --git a/models/crop-rotation.rkt b/models/crop-rotation.rkt
index 630e493..cb6832e 100644
--- a/models/crop-rotation.rkt
+++ b/models/crop-rotation.rkt
@@ -5,30 +5,28 @@
crop-rotation-id
(rename-out [crop-rotation-rotation-date crop-rotation-date]
[crop-rotation-requirement-proportions crop-rotation-requirements])
- (contract-out [create-crop-rotation!
- (-> string? requirement-proportion-hash/c crop-rotation?)]
- [get-crop-rotations (-> (listof crop-rotation?))]
- [get-crop-rotation
- (->* () (#:id crop-rotation-id? #:date string?) (or/c crop-rotation? #f))]
- [get-latest-crop-rotation (-> (or/c crop-rotation? #f))]
- [delete-crop-rotation! (-> crop-rotation-or-id/c void?)]))
+ (contract-out
+ [create-crop-rotation! (-> string? requirement-proportion-hash/c crop-rotation?)]
+ [get-crop-rotations (-> (listof crop-rotation?))]
+ [get-crop-rotation (->* () (#:id db-id? #:date string?) (or/c crop-rotation? #f))]
+ [get-latest-crop-rotation (-> (or/c crop-rotation? #f))]
+ [delete-crop-rotation! (-> crop-rotation-or-id/c void?)]))
(require racket/contract
db
sql
"../db/conn.rkt"
- "nutrient.rkt"
- "crop-requirement.rkt")
+ "crop-requirement.rkt"
+ "utils.rkt")
(struct crop-rotation (id rotation-date requirement-proportions) #:transparent)
-(define crop-rotation-id? exact-nonnegative-integer?)
-(define crop-rotation-or-id/c (or/c crop-rotation? crop-rotation-id?))
+(define crop-rotation-or-id/c (or/c crop-rotation? db-id?))
(define requirement-proportion-hash/c (hash/c crop-requirement? (between/c 0 100) #:immutable #t))
(define (->cr-id cr-or-id)
(match cr-or-id
- [(? crop-rotation-id? id) id]
+ [(? db-id? id) id]
[(crop-rotation id _ _) id]
[#f (error '->nt-id "#f can not be converted to an id")]))
Copyright 2019--2026 Marius PETER