forked from Furumi/furumi-web
Let one account use the whole refresh run when others have nothing due
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
62141c0840
commit
0aead73135
7 files changed
+48
-43
No files matched your search
@@ -1179,7 +1179,7 @@ async fn postgres_podcast_fetch_state_is_local_only() {
|
||||
|
||||
// Scheduling: overdue first, future and unsubscribed podcasts skipped.
|
||||
let due: Vec<PodcastId> = store
|
||||
.podcasts_due_for_refresh(now, 10_000, usize::MAX)
|
||||
.podcasts_due_for_refresh(now, 10_000)
|
||||
.await
|
||||
.unwrap()
|
||||
.into_iter()
|
||||
@@ -1639,29 +1639,35 @@ async fn postgres_podcast_refresh_takes_accounts_in_turns() {
|
||||
.record_fetch_failure(quiet, &quiet_id, now, "x", Some(now - 1))
|
||||
.await
|
||||
.unwrap();
|
||||
let due = |per_account| {
|
||||
let store = store.clone();
|
||||
async move {
|
||||
store
|
||||
.podcasts_due_for_refresh(now, 100_000, per_account)
|
||||
.await
|
||||
.unwrap()
|
||||
.into_iter()
|
||||
.filter(|(user, ..)| [busy, quiet].contains(user))
|
||||
.map(|(user, id, _)| (user, id))
|
||||
.collect::<Vec<_>>()
|
||||
}
|
||||
};
|
||||
let due = store
|
||||
.podcasts_due_for_refresh(now, 100_000)
|
||||
.await
|
||||
.unwrap()
|
||||
.into_iter()
|
||||
.filter(|(user, ..)| [busy, quiet].contains(user))
|
||||
.map(|(user, id, _)| (user, id))
|
||||
.collect::<Vec<_>>();
|
||||
// One turn per account: the quiet account's only feed comes before the
|
||||
// busy account's second one, and the busy account still gets all of
|
||||
// its due feeds when the run has room (no per-account cap).
|
||||
assert_eq!(
|
||||
due(2).await,
|
||||
due,
|
||||
vec![
|
||||
(busy, busy_ids[0].clone()),
|
||||
(quiet, quiet_id.clone()),
|
||||
(busy, busy_ids[1].clone()),
|
||||
(busy, busy_ids[2].clone()),
|
||||
],
|
||||
"one turn per account, at most two each"
|
||||
);
|
||||
assert_eq!(due(usize::MAX).await.len(), 4);
|
||||
// With only one account due, a run takes up to the run limit from it.
|
||||
let alone = store
|
||||
.podcasts_due_for_refresh(now, 100_000)
|
||||
.await
|
||||
.unwrap()
|
||||
.into_iter()
|
||||
.filter(|(user, ..)| *user == busy)
|
||||
.count();
|
||||
assert_eq!(alone, 3);
|
||||
|
||||
// New subscriptions stop at the per-account limit.
|
||||
sqlx::query(
|
||||
@@ -1700,7 +1706,7 @@ async fn postgres_podcast_refresh_takes_accounts_in_turns() {
|
||||
/// Due groups of the given accounts only (other tests share the database).
|
||||
async fn due_for(store: &PodcastStore, users: &[i64], now: i64) -> runner::RefreshGroups {
|
||||
let due = store
|
||||
.podcasts_due_for_refresh(now, 100_000, usize::MAX)
|
||||
.podcasts_due_for_refresh(now, 100_000)
|
||||
.await
|
||||
.unwrap()
|
||||
.into_iter()
|
||||
|
||||
Reference in new issue
Block a user