Skip to content

Commit

Permalink
Fix ui shows wrong number of requests
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewbaldwin44 committed Nov 29, 2024
1 parent de9af6a commit c7edfb4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
15 changes: 8 additions & 7 deletions locust/webui/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import react from 'eslint-plugin-react';
import reactHooks from 'eslint-plugin-react-hooks';
import { fixupPluginRules } from '@eslint/compat';
import { FlatCompat } from '@eslint/eslintrc';
import js from '@eslint/js';
import typescriptEslint from '@typescript-eslint/eslint-plugin';
import tsParser from '@typescript-eslint/parser';
import _import from 'eslint-plugin-import';
import prettier from 'eslint-plugin-prettier';
import react from 'eslint-plugin-react';
import reactHooks from 'eslint-plugin-react-hooks';
import unusedImports from 'eslint-plugin-unused-imports';
import _import from 'eslint-plugin-import';
import { fixupPluginRules } from '@eslint/compat';
import tsParser from '@typescript-eslint/parser';

import path from 'node:path';
import { fileURLToPath } from 'node:url';
import js from '@eslint/js';
import { FlatCompat } from '@eslint/eslintrc';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
Expand Down
13 changes: 5 additions & 8 deletions locust/webui/src/hooks/useFetchStats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default function useFetchStats() {
const previousSwarmState = useRef(swarm.state);
const [shouldAddMarker, setShouldAddMarker] = useState(false);

const { data: statsData, refetch: refetchStats } = useGetStatsQuery();
const { data: statsData, refetch: refetchStats, isFetching, isLoading } = useGetStatsQuery();

const shouldRunRefetchInterval =
swarm.state === SWARM_STATE.SPAWNING || swarm.state == SWARM_STATE.RUNNING;
Expand All @@ -30,6 +30,7 @@ export default function useFetchStats() {
}

const {
state,
currentResponseTimePercentiles,
extendedStats,
stats,
Expand Down Expand Up @@ -80,15 +81,11 @@ export default function useFetchStats() {
userCount,
});
updateCharts(newChartEntry);
};

useEffect(() => {
if (statsData) {
setSwarm({ state: statsData.state });
}
}, [statsData && statsData.state]);
setSwarm({ state });
};

useInterval(updateStats, STATS_REFETCH_INTERVAL, {
useInterval(updateStats, STATS_REFETCH_INTERVAL + 100, {
shouldRunInterval: !!statsData && shouldRunRefetchInterval,
});

Expand Down

0 comments on commit c7edfb4

Please sign in to comment.