iz-core: reminder countdown uses due time, not mint time
Browse files at this commit7d488cd431cab798c658f8c3a197a5b6258f781cParent: 4a255c52 changed files +16 -11
crates/iz-core/src/store/turso_store.rsmodified+6 -1
| @@ -771,7 +771,12 @@ impl TursoStore { | ||
| 771 | 771 | // The mail falls due this many minutes before the clock; a meeting |
| 772 | 772 | // already inside the window warns the moment the write commits. |
| 773 | 773 | let due = (clock_at - Duration::minutes(i64::from(reminder_minutes))).max(now); |
| 774 | - let minutes_left = (clock_at - now).whole_minutes(); | |
| 774 | + // Remaining is what the reader has when the mail is due, not when | |
| 775 | + // the row is minted. A meeting two days out with a fifteen-minute | |
| 776 | + // lead must say "in 15 minutes", not the two days that sat on the | |
| 777 | + // queue. A meeting already inside the window is due now, so this | |
| 778 | + // is the minutes actually left. | |
| 779 | + let minutes_left = (clock_at - due).whole_minutes().max(0); | |
| 775 | 780 | |
| 776 | 781 | let mut rows = tx |
| 777 | 782 | .query( |
crates/iz-core/tests/store.rsmodified+10 -10
| @@ -7112,17 +7112,12 @@ async fn a_clocked_task_owes_each_assignee_one_reminder_before_the_meeting() { | ||
| 7112 | 7112 | let body = row.body.as_deref().unwrap(); |
| 7113 | 7113 | assert!(body.contains("The quarterly review"), "body was: {body}"); |
| 7114 | 7114 | assert!(body.contains("Meets at"), "body was: {body}"); |
| 7115 | - // The countdown is whole minutes at mint time, and a few ticks pass | |
| 7116 | - // between picking the clock and creating the task. | |
| 7117 | - let minutes: u32 = body | |
| 7118 | - .split("in ") | |
| 7119 | - .nth(1) | |
| 7120 | - .and_then(|rest| rest.split(' ').next()) | |
| 7121 | - .and_then(|n| n.parse().ok()) | |
| 7122 | - .unwrap_or(0); | |
| 7115 | + // Remaining is counted from when the mail falls due, not from mint: | |
| 7116 | + // a meeting two hours out with a fifteen-minute lead warns of fifteen | |
| 7117 | + // minutes, which is what the reader has when the mail actually lands. | |
| 7123 | 7118 | assert!( |
| 7124 | - (117..=120).contains(&minutes), | |
| 7125 | - "the countdown names the meeting two hours out: {body}" | |
| 7119 | + body.contains("in 15 minutes"), | |
| 7120 | + "the countdown names the lead, not the mint distance: {body}" | |
| 7126 | 7121 | ); |
| 7127 | 7122 | } |
| 7128 | 7123 | assert_eq!(rows[0].recipient, "emre@iz.sh"); |
| @@ -7160,6 +7155,11 @@ async fn the_reminder_falls_due_at_the_workspaces_own_lead() { | ||
| 7160 | 7155 | clock - Duration::minutes(60), |
| 7161 | 7156 | "an hour before the meeting, not the default quarter" |
| 7162 | 7157 | ); |
| 7158 | + let body = rows[0].body.as_deref().unwrap(); | |
| 7159 | + assert!( | |
| 7160 | + body.contains("in 60 minutes"), | |
| 7161 | + "the countdown follows the lead, not how far mint sat from the clock: {body}" | |
| 7162 | + ); | |
| 7163 | 7163 | let _ = std::fs::remove_dir_all(&dir); |
| 7164 | 7164 | } |
| 7165 | 7165 |