polls: don't continuously refresh closed polls and refresh less frequently #472

Merged
Oneric merged 2 commits from Oneric/akkoma-fe:poll-upd-frequency-reduction into develop 2026-01-24 18:30:00 +00:00
Showing only changes of commit 8d8e6d979a - Show all commits

polls: reduce frequency of update fetches

Thirty seconds is much quicker than any other auto-refreshes in the
interface. Emitting a request for every users and tab with the poll
loaded this frequently can add up to a noteworthy total on the backend.

This is significantly worsened by our backend currently synchronously
fetching and updating the status of remote polls when queried about
while initiating a remote fetch for every incoming request inbetween
the last refetch passing the  age threshold and the first current fetch
suceeding and completing its db transaction.
Oneric 2026-01-14 00:00:00 +00:00

View file

@ -1,5 +1,7 @@
import { merge } from 'lodash'
const POLL_UPDATE_FREQUENCY = 150_000;
const polls = {
state: {
// Contains key = id, value = number of trackers for this poll
@ -44,13 +46,13 @@ const polls = {
if (rootState.polls.trackedPolls[pollId]) {
dispatch('updateTrackedPoll', pollId)
}
}, 30 * 1000)
}, POLL_UPDATE_FREQUENCY)
commit('mergeOrAddPoll', poll)
})
},
trackPoll ({ rootState, commit, dispatch }, pollId) {
if (!rootState.polls.trackedPolls[pollId]) {
setTimeout(() => dispatch('updateTrackedPoll', pollId), 30 * 1000)
setTimeout(() => dispatch('updateTrackedPoll', pollId), POLL_UPDATE_FREQUENCY)
}
commit('trackPoll', pollId)
},