fix: revert nginx timeouts; fire stats fetch on mount regardless of interval

This commit is contained in:
Jonathan Caicedo 2026-05-23 14:20:13 -04:00
parent a2c69be861
commit 0d1d1f2722
3 changed files with 14 additions and 14 deletions

View file

@ -21,8 +21,6 @@ server {
location / {
include uwsgi_params;
uwsgi_pass unix:/app/uwsgi.sock;
uwsgi_read_timeout 300s;
uwsgi_send_timeout 300s;
}
location /assets/ {

View file

@ -212,19 +212,19 @@ const StatsPage = () => {
}
}, [setVodStats]);
// Always fetch once on mount, regardless of polling interval setting
useEffect(() => {
fetchChannelStats();
fetchVODStats();
}, [fetchChannelStats, fetchVODStats]);
// Set up polling for stats when on stats page
useEffect(() => {
const location = window.location;
const isOnStatsPage = location.pathname === '/stats';
const isOnStatsPage = window.location.pathname === '/stats';
if (isOnStatsPage && refreshInterval > 0) {
setIsPollingActive(true);
// Initial fetch
fetchChannelStats();
fetchVODStats();
// Set up interval
const interval = setInterval(() => {
fetchChannelStats();
fetchVODStats();
@ -239,8 +239,6 @@ const StatsPage = () => {
}
}, [refreshInterval, fetchChannelStats, fetchVODStats]);
// Initial fetch is handled by the polling useEffect above (it fetches immediately on mount)
useEffect(() => {
console.log('Processing channel stats:', channelStats);
if (

View file

@ -297,19 +297,23 @@ describe('StatsPage', () => {
vi.useRealTimers();
});
it('does not poll when interval is 0', async () => {
it('does not poll when interval is 0 but still fetches once on mount', async () => {
vi.useFakeTimers();
useLocalStorage.mockReturnValue([0, mockSetRefreshInterval]);
render(<StatsPage />);
expect(fetchActiveChannelStats).toHaveBeenCalledTimes(0);
// Should still fetch once on mount even with interval = 0
expect(fetchActiveChannelStats).toHaveBeenCalledTimes(1);
expect(getVODStats).toHaveBeenCalledTimes(1);
await act(async () => {
vi.advanceTimersByTime(10000);
});
expect(fetchActiveChannelStats).toHaveBeenCalledTimes(0);
// Should not have polled count stays at 1
expect(fetchActiveChannelStats).toHaveBeenCalledTimes(1);
expect(getVODStats).toHaveBeenCalledTimes(1);
vi.useRealTimers();
});