Digest window: at least a day back again (WINDOW_MIN_HOURS, map 16.22.2); her last wake opens it only when it is older
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
7d43695284
commit
3bee54f47f
2 changed files with 9 additions and 4 deletions
|
|
@ -38,6 +38,8 @@ use crate::queue::{any_of, in_force, of_kind};
|
|||
|
||||
/// The window when she has not woken before, and the furthest back it ever reaches.
|
||||
const WINDOW_MAX_DAYS: i64 = 7;
|
||||
/// The least the window reaches back (map 16.22.2): a day, however recently she woke.
|
||||
const WINDOW_MIN_HOURS: i64 = 24;
|
||||
/// One page of the forge's pull requests, and how many pages of one repo a read takes: 200 moved in a week is past
|
||||
/// anything the coop has seen, and a repo past it fails the read rather than show part of it.
|
||||
const PULLS_PAGE: usize = 50;
|
||||
|
|
@ -47,10 +49,12 @@ const EVENTS_PAGE: u32 = 200;
|
|||
/// The whole of one forge call.
|
||||
const FORGE_TIMEOUT: Duration = Duration::from_secs(10);
|
||||
|
||||
/// Where the window opens: her last wake, at most a week before `now`; a week when she has not woken before.
|
||||
/// Where the window opens: her last wake, but at least a day and at most a week before `now`; a week when she has not
|
||||
/// woken before.
|
||||
pub(crate) fn since(last_wake: Option<DateTime<Utc>>, now: DateTime<Utc>) -> DateTime<Utc> {
|
||||
let earliest = now - chrono::Duration::days(WINDOW_MAX_DAYS);
|
||||
last_wake.map_or(earliest, |at| at.clamp(earliest, now))
|
||||
let latest = now - chrono::Duration::hours(WINDOW_MIN_HOURS);
|
||||
last_wake.map_or(earliest, |at| at.clamp(earliest, latest))
|
||||
}
|
||||
|
||||
/// What moved in her domain, as read: the facts the section is rendered from. A harness fixture carries the same
|
||||
|
|
|
|||
|
|
@ -129,11 +129,12 @@ fn worked_on() -> TestMind {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn the_window_opens_at_her_last_wake_at_most_a_week_back() {
|
||||
fn the_window_opens_at_her_last_wake_at_least_a_day_and_at_most_a_week_back() {
|
||||
let now = now();
|
||||
assert_eq!(super::since(None, now), now - Duration::days(7), "never woken: a week");
|
||||
assert_eq!(super::since(Some(now - Duration::days(30)), now), now - Duration::days(7));
|
||||
assert_eq!(super::since(Some(now - Duration::minutes(10)), now), now - Duration::minutes(10), "her last wake, however recent");
|
||||
assert_eq!(super::since(Some(now - Duration::days(2)), now), now - Duration::days(2), "her last wake");
|
||||
assert_eq!(super::since(Some(now - Duration::minutes(5)), now), now - Duration::hours(24), "a wake five minutes ago still shows a day (Soul p6)");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
Loading…
Reference in a new issue