Skip to content

Commit

Permalink
reduce useless call
Browse files Browse the repository at this point in the history
  • Loading branch information
yufansong committed Feb 22, 2024
1 parent acfe6ad commit 5ab8509
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions dashboard/pages/fragment_graph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -253,18 +253,19 @@ export default function Streaming() {
const toast = useErrorToast()

useEffect(() => {
const interval = setInterval(() => {
const fetchNewBP = async () => {
const newBP = await getBackPressureWithoutPrometheus()
setPreviousBP(currentBP)
setCurrentBP(newBP)
}

fetchNewBP().catch(console.error)
}, INTERVAL)
if (backPressureDataSourceAlgo === "Embedded") {
const interval = setInterval(() => {
const fetchNewBP = async () => {
const newBP = await getBackPressureWithoutPrometheus()
setPreviousBP(currentBP)
setCurrentBP(newBP)
}

return () => clearInterval(interval)
}, [currentBP])
fetchNewBP().catch(console.error)
}, INTERVAL)
return () => clearInterval(interval)
}
}, [currentBP, backPressureDataSourceAlgo])

useEffect(() => {
if (currentBP !== null && previousBP !== null) {
Expand Down

0 comments on commit 5ab8509

Please sign in to comment.