diff --git a/client/app/pages/admin/Jobs.jsx b/client/app/pages/admin/Jobs.jsx index 44dc6e3bf9..40a8cfa61d 100644 --- a/client/app/pages/admin/Jobs.jsx +++ b/client/app/pages/admin/Jobs.jsx @@ -25,20 +25,29 @@ class Jobs extends React.Component { workers: [], }; + _refreshTimer = null; + componentDidMount() { recordEvent('view', 'page', 'admin/rq_status'); - $http - .get('/api/admin/queries/rq_status') - .then(({ data }) => this.processQueues(data)) - .catch(error => this.handleError(error)); + this.refresh(); } componentWillUnmount() { // Ignore data after component unmounted + clearTimeout(this._refreshTimer); this.processQueues = () => {}; this.handleError = () => {}; } + refresh = () => { + $http + .get('/api/admin/queries/rq_status') + .then(({ data }) => this.processQueues(data)) + .catch(error => this.handleError(error)); + + this._refreshTimer = setTimeout(this.refresh, 60 * 1000); + }; + processQueues = ({ queues, workers }) => { const queueCounters = values(queues).map(({ started, ...rest }) => ({ started: started.length,