diff options
| author | Joe Carstairs <jcarstairs@scottlogic.com> | 2025-07-15 14:41:01 +0100 |
|---|---|---|
| committer | Joe Carstairs <jcarstairs@scottlogic.com> | 2025-07-15 14:41:01 +0100 |
| commit | ee6d4d87ffe36fe286e9976a7785a83d0d340c92 (patch) | |
| tree | 71f78b1f1d61c5ebb5f5505c5a7091629895071e | |
| parent | ea21b9246ca930c88b9092156767b437447b8280 (diff) | |
add req-035
| -rw-r--r-- | requirements/catalogue/req-030.md | 25 | ||||
| -rw-r--r-- | requirements/catalogue/req-035.md | 27 |
2 files changed, 29 insertions, 23 deletions
diff --git a/requirements/catalogue/req-030.md b/requirements/catalogue/req-030.md index cb27f11..2cb1bdd 100644 --- a/requirements/catalogue/req-030.md +++ b/requirements/catalogue/req-030.md @@ -12,8 +12,8 @@ Inputs: 2. If more than one bucket exists with the name, `name`, then panic. 3. Let `bucket` be the bucket with the given name. 4. Let `cache_key = bucket.balance_cache_key`. -5. Let `is_up_to_date` be the result of the sub-procedure, - `is_bucket_balance_up_to_date(bucket)`, as described below. +5. Let `is_up_to_date` be the result of the procedure, + `is_bucket_balance_up_to_date(bucket)`, as described in req-035. 6. If `is_up_to_date = TRUE`, then return `bucket.balance`. 7. Let `transaction_sum` be the sum over the property, `amount`, of all transactions `t` such that `t.bucket_id = bucket.id`. @@ -21,25 +21,4 @@ Inputs: that `d.bucket_id = bucket.id`. 9. Return `drip_sum - transaction_sum`. -## is_bucket_balance_up_to_date - -Inputs: - -- A bucket, `bucket` - -1. Let `cache_key = bucket.balance_cache_key`. -2. If `cache_key` is not in the format, `<string>:<string>`, then return FALSE. -3. Let `drip_id` be the part of `cache_key` before the `:`. -4. If there is no drip with the ID, `drip_id`, then return FALSE. -5. Let `drip` be the drip with the ID, `drip_id`. -6. If there is a drip, `drip_2`, such that `drip_2.date > drip.date` and - `drip.bucket_id = bucket.id`, then return FALSE. -7. Let `transaction_id` be the part of `cache_key` after the `:`. -8. If there is no transaction with the ID, `transaction_id`, then return FALSE. -9. Let `transaction` be the transaction with the ID, `transaction_id`. -10. If there is a transaction, `transaction_2`, such that - `transaction_2.timestamp >= transaction.timestamp` and - `transaction.bucket_id = bucket.id`, then return FALSE. -11. Return TRUE. - Source: req-029 diff --git a/requirements/catalogue/req-035.md b/requirements/catalogue/req-035.md new file mode 100644 index 0000000..0dc9aaf --- /dev/null +++ b/requirements/catalogue/req-035.md @@ -0,0 +1,27 @@ +# req-035 + +Schist must implement the procedure described below as +`is_bucket_balance_up_to_date`. + +## is_bucket_balance_up_to_date + +Inputs: + +- A bucket, `bucket` + +1. Let `cache_key = bucket.balance_cache_key`. +2. If `cache_key` is not in the format, `<string>:<string>`, then return FALSE. +3. Let `drip_id` be the part of `cache_key` before the `:`. +4. If there is no drip with the ID, `drip_id`, then return FALSE. +5. Let `drip` be the drip with the ID, `drip_id`. +6. If there is a drip, `drip_2`, such that `drip_2.date > drip.date` and + `drip.bucket_id = bucket.id`, then return FALSE. +7. Let `transaction_id` be the part of `cache_key` after the `:`. +8. If there is no transaction with the ID, `transaction_id`, then return FALSE. +9. Let `transaction` be the transaction with the ID, `transaction_id`. +10. If there is a transaction, `transaction_2`, such that + `transaction_2.timestamp >= transaction.timestamp` and + `transaction.bucket_id = bucket.id`, then return FALSE. +11. Return TRUE. + +Source: req-030
\ No newline at end of file |
