semantic bufo search find-bufo.com
bufo
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix(bot): exclude future timestamps from rate limit count

stagger-seeded last_posted entries are in the future, which inflated
the recent post count. filter to only count timestamps <= now.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

zzstoatzz af53f817 c8fee455

+7 -2
+7 -2
bot/src/stats.zig
··· 374 374 375 375 /// Count how many bufos were posted within the last `window_secs` seconds. 376 376 /// Uses the persisted last_posted timestamps, so survives restarts. 377 + /// Count how many bufos were posted within the last `window_secs` seconds. 378 + /// Uses the persisted last_posted timestamps, so survives restarts. 379 + /// Ignores future timestamps (from cold-start stagger seeding). 377 380 pub fn recentPostCount(self: *Stats, window_secs: i64) u32 { 378 381 self.bufo_mutex.lockUncancelable(io); 379 382 defer self.bufo_mutex.unlock(io); 380 383 381 - const cutoff = timestamp() - window_secs; 384 + const now = timestamp(); 385 + const cutoff = now - window_secs; 382 386 var count: u32 = 0; 383 387 var iter = self.last_posted.iterator(); 384 388 while (iter.next()) |entry| { 385 - if (entry.value_ptr.* > cutoff) count += 1; 389 + const ts = entry.value_ptr.*; 390 + if (ts > cutoff and ts <= now) count += 1; 386 391 } 387 392 return count; 388 393 }