...
|
...
|
@@ -9,6 +9,9 @@ const jp = require('jsonpath'); |
|
|
const config = require('../../../config/config');
|
|
|
const ErrorModel = require('../models/errorModel');
|
|
|
const SlowRouteModel = require('../models/slowRouteModel');
|
|
|
const SortRouteModel = require('../models/sortRouteModel');
|
|
|
const SortApiModel = require('../models/sortApiModel');
|
|
|
const SortClientModel = require('../models/sortClientRouteModel');
|
|
|
|
|
|
const endpoint = (server) => `http://${server.host}:${server.port}`;
|
|
|
|
...
|
...
|
@@ -195,6 +198,75 @@ const profile_service = { |
|
|
const result = await errorModel.getList(app, host, type, time, code, api, route, start, length);
|
|
|
|
|
|
return result;
|
|
|
},
|
|
|
async sort_route_time(ctx, app, time) {
|
|
|
const sortRouteModel = new SortRouteModel(ctx);
|
|
|
const result = await sortRouteModel.getTimeList(app, time);
|
|
|
|
|
|
return result;
|
|
|
},
|
|
|
async sort_route_count(ctx, app, time) {
|
|
|
const sortRouteModel = new SortRouteModel(ctx);
|
|
|
const result = await sortRouteModel.getCountList(app, time);
|
|
|
|
|
|
return result;
|
|
|
},
|
|
|
async sort_api_time(ctx, app, time) {
|
|
|
const sortRouteModel = new SortApiModel(ctx);
|
|
|
const result = await sortRouteModel.getTimeList(app, time);
|
|
|
|
|
|
return result;
|
|
|
},
|
|
|
async sort_api_count(ctx, app, time) {
|
|
|
const sortRouteModel = new SortApiModel(ctx);
|
|
|
const result = await sortRouteModel.getCountList(app, time);
|
|
|
|
|
|
return result;
|
|
|
},
|
|
|
async getApp(ctx) {
|
|
|
let model = new ErrorModel(ctx);
|
|
|
let app = await model.getApp().then(r => r.map(fp.prop('app')));
|
|
|
|
|
|
return app;
|
|
|
},
|
|
|
async sort_server_route(ctx, app, time) {
|
|
|
let routeTime = await this.sort_route_time(ctx, app, time);
|
|
|
let routeCount = await this.sort_route_count(ctx, app, time);
|
|
|
|
|
|
let sortRouteTime = _.orderBy(routeTime, ['avg'], ['desc']);
|
|
|
let sortRouteCount = _.orderBy(routeCount, ['count'], ['desc']);
|
|
|
|
|
|
return {time: sortRouteTime, count: sortRouteCount};
|
|
|
},
|
|
|
async sort_server_api(ctx, app, time) {
|
|
|
let routeTime = await this.sort_api_time(ctx, app, time);
|
|
|
let routeCount = await this.sort_api_count(ctx, app, time);
|
|
|
|
|
|
let sortRouteTime = _.orderBy(routeTime, ['avg'], ['desc']);
|
|
|
let sortRouteCount = _.orderBy(routeCount, ['count'], ['desc']);
|
|
|
|
|
|
return {time: sortRouteTime, count: sortRouteCount};
|
|
|
},
|
|
|
async sort_client_time(ctx, app, time) {
|
|
|
const newClientTime = new SortClientModel(ctx);
|
|
|
const result = await newClientTime.getFirstScreenTimeList(app, time);
|
|
|
|
|
|
return result;
|
|
|
},
|
|
|
async sort_client_count(ctx, app, time) {
|
|
|
const newClientCount = new SortClientModel(ctx);
|
|
|
const result = await newClientCount.getCountList(app, time);
|
|
|
|
|
|
return result;
|
|
|
},
|
|
|
async sort_client_route(ctx, app, time) {
|
|
|
let routeTime = await this.sort_client_time(ctx, app, time);
|
|
|
let routeCount = await this.sort_client_count(ctx, app, time);
|
|
|
|
|
|
let sortRouteTime = _.orderBy(routeTime, ['avg'], ['desc']);
|
|
|
let sortRouteCount = _.orderBy(routeCount, ['count'], ['desc']);
|
|
|
|
|
|
return {time: sortRouteTime, count: sortRouteCount};
|
|
|
}
|
|
|
};
|
|
|
|
...
|
...
|
@@ -219,7 +291,7 @@ const profile_controller = { |
|
|
let type = await model.getType().then(r => r.map(fp.prop('type')));
|
|
|
let code = await model.getCode().then(r => r.map(fp.prop('code')));
|
|
|
let route = await model.getRoute().then(r => r.map(fp.prop('route')));
|
|
|
let api = await model.getApi().then(r => r.map(fp.prop('api')));
|
|
|
let api = await model.getApi().then(r => r.dmap(fp.prop('api')));
|
|
|
|
|
|
await ctx.render('action/profile_error', {hostName, app, type, code, route, api});
|
|
|
},
|
...
|
...
|
@@ -238,8 +310,49 @@ const profile_controller = { |
|
|
|
|
|
const result = await profile_service.error(ctx, app, host, type, time, code, api, route, start, length);
|
|
|
ctx.body = Object.assign({}, result, {draw});
|
|
|
}
|
|
|
},
|
|
|
async sort_route(ctx) {
|
|
|
const result = await profile_service.getApp(ctx);
|
|
|
|
|
|
await ctx.render('action/sort_route', {app: result})
|
|
|
},
|
|
|
async sort_route_list(ctx) {
|
|
|
const app = ctx.query.app;
|
|
|
const time = ctx.query.time;
|
|
|
const result = await profile_service.sort_server_route(ctx, app, time);
|
|
|
|
|
|
await ctx.render('action/sort_route_list', Object.assign({}, {
|
|
|
layout: false
|
|
|
}, result));
|
|
|
},
|
|
|
async sort_api(ctx) {
|
|
|
const result = await profile_service.getApp(ctx);
|
|
|
|
|
|
await ctx.render('action/sort_api', {app: result})
|
|
|
},
|
|
|
async sort_api_list(ctx) {
|
|
|
const app = ctx.query.app;
|
|
|
const time = ctx.query.time;
|
|
|
const result = await profile_service.sort_server_api(ctx, app, time);
|
|
|
|
|
|
await ctx.render('action/sort_api_list', Object.assign({}, {
|
|
|
layout: false
|
|
|
}, result));
|
|
|
},
|
|
|
async sort_client(ctx) {
|
|
|
const result = await profile_service.getApp(ctx);
|
|
|
|
|
|
await ctx.render('action/sort_client', {app: result})
|
|
|
},
|
|
|
async sort_client_list(ctx) {
|
|
|
const app = ctx.query.app;
|
|
|
const time = ctx.query.time;
|
|
|
const result = await profile_service.sort_client_route(ctx, app, time);
|
|
|
|
|
|
await ctx.render('action/sort_client_list', Object.assign({}, {
|
|
|
layout: false
|
|
|
}, result));
|
|
|
}
|
|
|
};
|
|
|
|
|
|
r.get('/server', profile_controller.server_mean_report_index);
|
...
|
...
|
@@ -248,4 +361,13 @@ r.get('/server.json', profile_controller.server_mean_report_json); |
|
|
r.get('/error', profile_controller.error_report_index);
|
|
|
r.get('/error.json', profile_controller.error_report_json);
|
|
|
|
|
|
r.get('/sort_route', profile_controller.sort_route);
|
|
|
r.post('/sort_route_list', profile_controller.sort_route_list);
|
|
|
|
|
|
r.get('/sort_api', profile_controller.sort_api);
|
|
|
r.post('/sort_api_list', profile_controller.sort_api_list);
|
|
|
|
|
|
r.get('/sort_client', profile_controller.sort_client);
|
|
|
r.post('/sort_client_list', profile_controller.sort_client_list);
|
|
|
|
|
|
module.exports = r; |
|
|
\ No newline at end of file |
...
|
...
|
|