Skip to content

Commit

Permalink
auto-refresh data RQ jobs admin page (#4298)
Browse files Browse the repository at this point in the history
  • Loading branch information
Omer Lachish authored Nov 11, 2019
1 parent 80878ab commit f19d242
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions client/app/pages/admin/Jobs.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit f19d242

Please sign in to comment.