···328328329329### 4.2 Fetch Schedule
330330331331-The scheduler uses a single fixed interval with in-flight deduplication:
331331+The scheduler uses a configurable tick interval with in-flight deduplication:
332332333333-- **Tick interval**: The scheduler checks for stale feeds every 5 minutes
333333+- **Tick interval**: The scheduler checks for stale feeds every `GLEAN_FETCH_INTERVAL` (default 5 minutes)
334334- **Staleness threshold**: Feeds not fetched in the last 30 minutes are eligible
335335- **Subscriber filter**: Only feeds with `subscriber_count > 0` are fetched
336336- **In-flight dedup**: If a feed is already being fetched (e.g., manual refresh and background scheduler overlap), the second caller waits for the first to complete rather than fetching again
···17171818 _, err = tx.ExecContext(ctx, `
1919 INSERT INTO follow_distances (user_a, user_b, distance)
2020- SELECT user_did, target_did, 1 FROM follows WHERE user_did != target_did
2121- UNION ALL
2222- SELECT f1.user_did, f2.target_did, 2
2323- FROM follows f1
2424- JOIN follows f2 ON f1.target_did = f2.user_did
2525- WHERE f1.user_did != f2.target_did
2020+ SELECT user_a, user_b, MIN(distance) FROM (
2121+ SELECT user_did AS user_a, target_did AS user_b, 1 AS distance FROM follows WHERE user_did != target_did
2222+ UNION ALL
2323+ SELECT f1.user_did, f2.target_did, 2
2424+ FROM follows f1
2525+ JOIN follows f2 ON f1.target_did = f2.user_did
2626+ WHERE f1.user_did != f2.target_did
2727+ ) GROUP BY user_a, user_b
2628 `)
2729 if err != nil {
2830 return err