John Smith commited on 2021-325 22:03:58
Showing 1 changed files, with 25 additions and 0 deletions.
* `review.update` to update a `Prompt` upon review * `review.should` to check if a `Prompt` should be reviewed
| ... | ... |
@@ -0,0 +1,25 @@ |
| 1 |
+--[[ |
|
| 2 |
+ stuff to help with the review mechanics |
|
| 3 |
+]] |
|
| 4 |
+ |
|
| 5 |
+--[[ |
|
| 6 |
+ manipulates `Prompt` `prompt` in-place as it should be |
|
| 7 |
+ when reviewed at timestamp `revtime` with review success `revsucc` |
|
| 8 |
+]] |
|
| 9 |
+local function update(prompt, revtime, revsucc) |
|
| 10 |
+ if revsucc then |
|
| 11 |
+ prompt.delay = 2 * (revtime - prompt.time) |
|
| 12 |
+ else |
|
| 13 |
+ prompt.delay = 64 |
|
| 14 |
+ end |
|
| 15 |
+ prompt.time = revtime |
|
| 16 |
+end |
|
| 17 |
+ |
|
| 18 |
+--[[ |
|
| 19 |
+ checks (returns boolean) if `Prompt` `prompt` should be reviewed now |
|
| 20 |
+]] |
|
| 21 |
+local function should(prompt) |
|
| 22 |
+ return os.time() - prompt.time >= prompt.delay |
|
| 23 |
+end |
|
| 24 |
+ |
|
| 25 |
+return { update = update, should = should }
|
|
| 0 | 26 |