From 9d70ff56e7d45ca6d26ee5725cdea6288585358b Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Tue, 19 Apr 2016 09:58:02 +0200 Subject: [PATCH] SONAR-7553 use api/ce/activity_status to get number of pending and failing tasks --- server/sonar-web/src/main/js/api/ce.js | 9 +++++++++ .../main/js/apps/background-tasks/store/actions.js | 14 ++++++-------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/server/sonar-web/src/main/js/api/ce.js b/server/sonar-web/src/main/js/api/ce.js index e46eb236026..66c6b3dc8ab 100644 --- a/server/sonar-web/src/main/js/api/ce.js +++ b/server/sonar-web/src/main/js/api/ce.js @@ -30,6 +30,15 @@ export function getActivity (data) { return $.get(url, data); } +export function getStatus (componentId) { + const url = window.baseUrl + '/api/ce/activity_status'; + const data = {}; + if (componentId) { + Object.assign(data, { componentId }); + } + return getJSON(url, data); +} + export function getTask (id) { const url = window.baseUrl + '/api/ce/task'; return getJSON(url, { id }).then(r => r.task); diff --git a/server/sonar-web/src/main/js/apps/background-tasks/store/actions.js b/server/sonar-web/src/main/js/apps/background-tasks/store/actions.js index 0a7ef85b277..095f659f0ca 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/store/actions.js +++ b/server/sonar-web/src/main/js/apps/background-tasks/store/actions.js @@ -18,12 +18,10 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import _ from 'underscore'; -import { getTypes, getActivity, cancelAllTasks, cancelTask as cancelTaskAPI } from '../../../api/ce'; +import { getTypes, getActivity, getStatus, cancelAllTasks, cancelTask as cancelTaskAPI } from '../../../api/ce'; import { STATUSES, ALL_TYPES, CURRENTS, DEBOUNCE_DELAY } from '../constants'; -const PAGE_SIZE = 1000; - export const INIT = 'INIT'; export const REQUEST_TASKS = 'REQUEST_TASKS'; export const RECEIVE_TASKS = 'RECEIVE_TASKS'; @@ -151,16 +149,16 @@ function fetchTasks (filters) { dispatch(requestTasks(filters)); return Promise.all([ - getActivity(parameters) + getActivity(parameters), + getStatus(parameters.componentId) ]).then(responses => { - const [activity] = responses; + const [activity, status] = responses; const tasks = activity.tasks; dispatch(receiveTasks(tasks)); - // FIXME request real numbers - const pendingCount = 0; - const failingCount = 0; + const pendingCount = status.pending; + const failingCount = status.failing; dispatch(receiveStats({ pendingCount, failingCount })); }); -- 2.39.5