Browse Source

Detections count #516 (#517)

pull/1/head
Evgeny Smyshlyaev 6 years ago committed by rozetko
parent
commit
60af0f40e1
  1. 7
      server/src/controllers/analytics_controller.ts
  2. 1
      server/src/index.ts

7
server/src/controllers/analytics_controller.ts

@ -28,6 +28,8 @@ let alertService: AlertService = undefined;
let grafanaAvailableWebhok: Function = undefined; let grafanaAvailableWebhok: Function = undefined;
let dataPuller: DataPuller; let dataPuller: DataPuller;
let detectionsCount: number = 0;
function onTaskResult(taskResult: TaskResult) { function onTaskResult(taskResult: TaskResult) {
let id = taskResult._id; let id = taskResult._id;
@ -47,6 +49,7 @@ function onTaskResult(taskResult: TaskResult) {
} }
async function onDetect(detectionResult: DetectionResult) { async function onDetect(detectionResult: DetectionResult) {
detectionsCount++;
let id = detectionResult.analyticUnitId; let id = detectionResult.analyticUnitId;
let payload = await processDetectionResult(id, detectionResult); let payload = await processDetectionResult(id, detectionResult);
await Promise.all([ await Promise.all([
@ -365,6 +368,10 @@ export function getTaskResolversLength(): number {
return taskResolvers.size; return taskResolvers.size;
} }
export function getDetectionsCount(): number {
return detectionsCount;
}
export function isAnalyticReady(): boolean { export function isAnalyticReady(): boolean {
return analyticsService.ready; return analyticsService.ready;
} }

1
server/src/index.ts

@ -67,6 +67,7 @@ async function init() {
tasksQueueLength: AnalyticsController.getQueueLength() tasksQueueLength: AnalyticsController.getQueueLength()
}, },
awaitedTasksNumber: AnalyticsController.getTaskResolversLength(), awaitedTasksNumber: AnalyticsController.getTaskResolversLength(),
detectionsCount: AnalyticsController.getDetectionsCount(),
nodeVersion: process.version, nodeVersion: process.version,
packageVersion: PACKAGE_VERSION, packageVersion: PACKAGE_VERSION,
npmUserAgent: process.env.npm_config_user_agent, npmUserAgent: process.env.npm_config_user_agent,

Loading…
Cancel
Save