polls: don't continuously refresh closed polls and refresh less frequently #472
1 changed files with 4 additions and 2 deletions
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.
commit
8d8e6d979a
|
|
@ -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)
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue