Browse Source

small clearup

pull/1/head
Alexey Velikiy 7 years ago
parent
commit
878ab7fd04
  1. 4
      server/src/routes/analytic_units_router.ts
  2. 3
      server/src/services/notification_service.ts

4
server/src/routes/analytic_units_router.ts

@ -8,15 +8,13 @@ import { saveTargets } from '../controllers/metrics_controler';
async function sendStatus(ctx: Router.IRouterContext) {
try {
let id = ctx.request.query.id;
let name = ctx.request.query.name;
if(id === undefined) {
throw new Error('Id is undefined');
}
let unit = AnalyticUnit.findById(id);
if(unit.status === undefined) {
throw new Error('No status for ' + name);
throw new Error('status is undefined');
}
ctx.response.body = { status: unit.status, errorMessage: unit.error };
} catch(e) {

3
server/src/services/notification_service.ts

@ -3,6 +3,7 @@ import { findById } from '../models/analytic_unit';
import axios from 'axios';
// TODO: send notification with payload without dep to AnalyticUnit
export async function sendNotification(predictorId, active) {
let anomalyName = findById(predictorId).name;
console.log('Notification ' + anomalyName);
@ -31,7 +32,7 @@ export async function sendNotification(predictorId, active) {
})
console.log(data);
} catch(err) {
console.error(`Can't send alert to ${endpoint}. Error: ${err}`)
console.error(`Can't send alert to ${endpoint}. Error: ${err}`);
}
}

Loading…
Cancel
Save