Browse Source

services vs controllers refactoring

pull/1/head
Alexey Velikiy 6 years ago
parent
commit
1d7b0e1d8d
  1. 2
      server/src/config.ts
  2. 8
      server/src/controllers/alerts_controller.ts
  3. 6
      server/src/controllers/analytics_controller.ts
  4. 2
      server/src/controllers/metrics_controler.ts
  5. 2
      server/src/controllers/segments_controller.ts
  6. 2
      server/src/index.ts
  7. 2
      server/src/models/analytic_unit.ts
  8. 2
      server/src/routes/alerts_router.ts
  9. 4
      server/src/routes/analytic_units_router.ts
  10. 4
      server/src/routes/segments_router.ts
  11. 0
      server/src/services/analytics_service.ts
  12. 0
      server/src/services/data_service.ts
  13. 0
      server/src/services/json_service.ts
  14. 0
      server/src/services/notification_service.ts

2
server/src/config.ts

@ -1,6 +1,6 @@
import * as path from 'path'; import * as path from 'path';
import * as fs from 'fs'; import * as fs from 'fs';
import { getJsonDataSync } from './controllers/json'; import { getJsonDataSync } from './services/json_service';
let configFile = path.join(__dirname, '../../config.json'); let configFile = path.join(__dirname, '../../config.json');

8
server/src/controllers/alerts_service.ts → server/src/controllers/alerts_controller.ts

@ -1,8 +1,8 @@
import { getJsonDataSync, writeJsonDataSync } from './json'; import { getJsonDataSync, writeJsonDataSync } from '../services/json_service';
import { AnalyticUnitId } from '../models/analytic_unit'; import { AnalyticUnitId } from '../models/analytic_unit';
import { runPredict } from './analytics_service'; import { runPredict } from './analytics_controller';
import { sendNotification } from './notification_service'; import { sendNotification } from '../services/notification_service';
import { getLabeledSegments } from './segments'; import { getLabeledSegments } from './segments_controller';
import { ANALYTIC_UNITS_PATH } from '../config'; import { ANALYTIC_UNITS_PATH } from '../config';

6
server/src/controllers/analytics_service.ts → server/src/controllers/analytics_controller.ts

@ -5,9 +5,9 @@ import {
setPredictionTime, setPredictionTime,
setStatus setStatus
} from '../models/analytic_unit' } from '../models/analytic_unit'
import { getTarget } from './metrics'; import { getTarget } from './metrics_controler';
import { getLabeledSegments, insertSegments, removeSegments } from './segments' import { getLabeledSegments, insertSegments, removeSegments } from './segments_controller'
import { AnalyticsConnection } from './analytics_connection' import { AnalyticsConnection } from '../services/analytics_service'
const taskMap = {}; const taskMap = {};

2
server/src/controllers/metrics.ts → server/src/controllers/metrics_controler.ts

@ -1,4 +1,4 @@
import { getJsonDataSync, writeJsonDataSync } from './json'; import { getJsonDataSync, writeJsonDataSync } from '../services/json_service';
import { METRICS_PATH } from '../config'; import { METRICS_PATH } from '../config';
import * as crypto from 'crypto'; import * as crypto from 'crypto';

2
server/src/controllers/segments.ts → server/src/controllers/segments_controller.ts

@ -1,4 +1,4 @@
import { getJsonDataSync, writeJsonDataSync } from './json'; import { getJsonDataSync, writeJsonDataSync } from '../services/json_service';
import { AnalyticUnitId, findById, save } from '../models/analytic_unit'; import { AnalyticUnitId, findById, save } from '../models/analytic_unit';
import { SEGMENTS_PATH } from '../config'; import { SEGMENTS_PATH } from '../config';

2
server/src/index.ts

@ -2,7 +2,7 @@ import { router as anomaliesRouter } from './routes/analytic_units_router';
import { router as segmentsRouter } from './routes/segments_router'; import { router as segmentsRouter } from './routes/segments_router';
import { router as alertsRouter } from './routes/alerts_router'; import { router as alertsRouter } from './routes/alerts_router';
import * as Data from './controllers/data'; import * as Data from './services/data_service';
import { HASTIC_PORT } from './config'; import { HASTIC_PORT } from './config';

2
server/src/models/analytic_unit.ts

@ -1,4 +1,4 @@
import { getJsonDataSync, writeJsonDataSync } from '../controllers/json' import { getJsonDataSync, writeJsonDataSync } from '../services/json_service'
import { ANALYTIC_UNITS_PATH } from '../config' import { ANALYTIC_UNITS_PATH } from '../config'
import * as crypto from 'crypto'; import * as crypto from 'crypto';

2
server/src/routes/alerts_router.ts

@ -1,5 +1,5 @@
import * as AnalyticUnit from '../models/analytic_unit'; import * as AnalyticUnit from '../models/analytic_unit';
import { getAlertsAnomalies, saveAlertsAnomalies } from '../controllers/alerts_service'; import { getAlertsAnomalies, saveAlertsAnomalies } from '../controllers/alerts_controller';
import * as Router from 'koa-router'; import * as Router from 'koa-router';

4
server/src/routes/analytic_units_router.ts

@ -2,8 +2,8 @@ import * as Router from 'koa-router';
import * as AnalyticUnit from '../models/analytic_unit'; import * as AnalyticUnit from '../models/analytic_unit';
import { runLearning } from '../controllers/analytics_service' import { runLearning } from '../controllers/analytics_controller'
import { saveTargets } from '../controllers/metrics'; import { saveTargets } from '../controllers/metrics_controler';
async function sendStatus(ctx: Router.IRouterContext) { async function sendStatus(ctx: Router.IRouterContext) {
try { try {

4
server/src/routes/segments_router.ts

@ -4,10 +4,10 @@ import {
getLabeledSegments, getLabeledSegments,
insertSegments, insertSegments,
removeSegments, removeSegments,
} from '../controllers/segments'; } from '../controllers/segments_controller';
import { AnalyticUnitId } from '../models/analytic_unit'; import { AnalyticUnitId } from '../models/analytic_unit';
import { runLearning } from '../controllers/analytics_service'; import { runLearning } from '../controllers/analytics_controller';
async function sendSegments(ctx: Router.IRouterContext) { async function sendSegments(ctx: Router.IRouterContext) {

0
server/src/controllers/analytics_connection.ts → server/src/services/analytics_service.ts

0
server/src/controllers/data.ts → server/src/services/data_service.ts

0
server/src/controllers/json.ts → server/src/services/json_service.ts

0
server/src/controllers/notification_service.ts → server/src/services/notification_service.ts

Loading…
Cancel
Save