|
|
@ -17,13 +17,13 @@ declare type DetectionStatus = { |
|
|
|
state: DetectionState |
|
|
|
state: DetectionState |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
declare type DetectionStatusResponce = { |
|
|
|
declare type DetectionStatusResponse = { |
|
|
|
timeranges: DetectionStatus[] |
|
|
|
timeranges: DetectionStatus[] |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let runnnedDetections: DetectionStatus[] = []; |
|
|
|
let runnnedDetections: DetectionStatus[] = []; |
|
|
|
|
|
|
|
|
|
|
|
export async function getDetectionStatus(ctx: Router.IRouterContext): Promise<DetectionStatusResponce> { |
|
|
|
export async function getDetectionStatus(ctx: Router.IRouterContext) { |
|
|
|
let id: AnalyticUnitId = ctx.request.query.id; |
|
|
|
let id: AnalyticUnitId = ctx.request.query.id; |
|
|
|
if(id === undefined || id === '') { |
|
|
|
if(id === undefined || id === '') { |
|
|
|
throw new Error('analyticUnitId (id) is missing'); |
|
|
|
throw new Error('analyticUnitId (id) is missing'); |
|
|
@ -40,7 +40,7 @@ export async function getDetectionStatus(ctx: Router.IRouterContext): Promise<De |
|
|
|
|
|
|
|
|
|
|
|
const previousRun = _.find(runnnedDetections, {id, from, to}); |
|
|
|
const previousRun = _.find(runnnedDetections, {id, from, to}); |
|
|
|
if(previousRun !== undefined) { |
|
|
|
if(previousRun !== undefined) { |
|
|
|
return { |
|
|
|
ctx.response.body = { |
|
|
|
timeranges: [ |
|
|
|
timeranges: [ |
|
|
|
previousRun |
|
|
|
previousRun |
|
|
|
] |
|
|
|
] |
|
|
@ -62,7 +62,7 @@ export async function getDetectionStatus(ctx: Router.IRouterContext): Promise<De |
|
|
|
_.find(runnnedDetections, {id, from, to}).state = DetectionState.FAILED; |
|
|
|
_.find(runnnedDetections, {id, from, to}).state = DetectionState.FAILED; |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
return { |
|
|
|
ctx.response.body = { |
|
|
|
timeranges: [ |
|
|
|
timeranges: [ |
|
|
|
currentRun |
|
|
|
currentRun |
|
|
|
] |
|
|
|
] |
|
|
|