From: Stas Vilchik Date: Tue, 19 Apr 2016 07:58:02 +0000 (+0200) Subject: SONAR-7553 use api/ce/activity_status to get number of pending and failing tasks X-Git-Tag: 5.5-RC2~10 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=refs%2Fpull%2F904%2Fhead;p=sonarqube.git SONAR-7553 use api/ce/activity_status to get number of pending and failing tasks --- 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 })); });