diff options
Diffstat (limited to 'server/sonar-web/src/main/js/api/time-machine.ts')
-rw-r--r-- | server/sonar-web/src/main/js/api/time-machine.ts | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/server/sonar-web/src/main/js/api/time-machine.ts b/server/sonar-web/src/main/js/api/time-machine.ts index 2f25912b191..ac77c7c8b41 100644 --- a/server/sonar-web/src/main/js/api/time-machine.ts +++ b/server/sonar-web/src/main/js/api/time-machine.ts @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { getJSON } from '../helpers/request'; -import { Paging } from '../app/types'; +import { Paging, BranchParameters } from '../app/types'; import throwGlobalError from '../app/utils/throwGlobalError'; export interface HistoryItem { @@ -39,25 +39,29 @@ interface TimeMachineResponse { } export function getTimeMachineData( - component: string, - metrics: string[], - other?: { branch?: string; p?: number; ps?: number; from?: string; to?: string } + data: { + component: string; + from?: string; + metrics: string; + p?: number; + ps?: number; + to?: string; + } & BranchParameters ): Promise<TimeMachineResponse> { - return getJSON('/api/measures/search_history', { - component, - metrics: metrics.join(), - ps: 1000, - ...other - }).catch(throwGlobalError); + return getJSON('/api/measures/search_history', data).catch(throwGlobalError); } export function getAllTimeMachineData( - component: string, - metrics: Array<string>, - other?: { branch?: string; p?: number; from?: string; to?: string }, + data: { + component: string; + metrics: string; + from?: string; + p?: number; + to?: string; + } & BranchParameters, prev?: TimeMachineResponse ): Promise<TimeMachineResponse> { - return getTimeMachineData(component, metrics, { ...other, ps: 1000 }).then(r => { + return getTimeMachineData({ ...data, ps: 1000 }).then(r => { const result = prev ? { measures: prev.measures.map((measure, idx) => ({ @@ -71,11 +75,6 @@ export function getAllTimeMachineData( if (result.paging.pageIndex * result.paging.pageSize >= result.paging.total) { return result; } - return getAllTimeMachineData( - component, - metrics, - { ...other, p: result.paging.pageIndex + 1 }, - result - ); + return getAllTimeMachineData({ ...data, p: result.paging.pageIndex + 1 }, result); }); } |