diff options
| author | Marius Peter <dev@marius-peter.com> | 2025-12-06 17:55:58 +0100 |
|---|---|---|
| committer | Marius Peter <dev@marius-peter.com> | 2025-12-06 17:55:58 +0100 |
| commit | c3557a7d5f54d7a9cb7fb2ece9487332c264236e (patch) | |
| tree | 1a87077374fba18f4ef38fb1ae084f6884e3cd5b /models/crop-rotation.rkt | |
| parent | c7ec194f4a6c3dc879c24d8075bfe05a7687f976 (diff) | |
Update model contracts.
Great use of my new modules to factor out common model contract logic!
Diffstat (limited to 'models/crop-rotation.rkt')
| -rw-r--r-- | models/crop-rotation.rkt | 22 |
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")])) |