Authored by htoooth

fix

@@ -22,8 +22,9 @@ const TABLE = { @@ -22,8 +22,9 @@ const TABLE = {
22 const DB_NAME = 'web-apm'; 22 const DB_NAME = 'web-apm';
23 23
24 const APP_NAME = { 24 const APP_NAME = {
25 - pc: 1,  
26 - h5: 2 25 + default: 0,
  26 + pc: 'yohobuy-node',
  27 + h5: 'yohobuywap-node'
27 }; 28 };
28 29
29 const APP_NAME2 = { 30 const APP_NAME2 = {
@@ -192,7 +193,7 @@ const profile_service = { @@ -192,7 +193,7 @@ const profile_service = {
192 const errorModel = new ErrorModel(ctx); 193 const errorModel = new ErrorModel(ctx);
193 const result = await errorModel.getList(app, start, length); 194 const result = await errorModel.getList(app, start, length);
194 195
195 - return {cde: 200, data: result}; 196 + return result;
196 } 197 }
197 }; 198 };
198 199
@@ -201,7 +202,7 @@ const profile_controller = { @@ -201,7 +202,7 @@ const profile_controller = {
201 await ctx.render('action/profile_server'); 202 await ctx.render('action/profile_server');
202 }, 203 },
203 async server_mean_report_json(ctx) { 204 async server_mean_report_json(ctx) {
204 - const app = APP_NAME[ctx.query.app] || 0; 205 + const app = APP_NAME[ctx.query.app] || APP_NAME.default;
205 const start = parseInt(ctx.query.start) || 0; 206 const start = parseInt(ctx.query.start) || 0;
206 const length = parseInt(ctx.query.length) || 10; 207 const length = parseInt(ctx.query.length) || 10;
207 const draw = ctx.query.draw; 208 const draw = ctx.query.draw;
@@ -213,7 +214,7 @@ const profile_controller = { @@ -213,7 +214,7 @@ const profile_controller = {
213 await ctx.render('action/profile_error'); 214 await ctx.render('action/profile_error');
214 }, 215 },
215 async error_report_json(ctx) { 216 async error_report_json(ctx) {
216 - const app = APP_NAME[(ctx.query.app)] || 0; 217 + const app = APP_NAME[(ctx.query.app)] || APP_NAME.default;
217 const start = parseInt(ctx.query.start) || 0; 218 const start = parseInt(ctx.query.start) || 0;
218 const length = parseInt(ctx.query.length) || 10; 219 const length = parseInt(ctx.query.length) || 10;
219 const draw = ctx.query.draw; 220 const draw = ctx.query.draw;
1 const model = require('../../../lib/model'); 1 const model = require('../../../lib/model');
2 const mysqlPromise = require('../../../lib/mysql-apm'); 2 const mysqlPromise = require('../../../lib/mysql-apm');
3 -const vars = require('./vars');  
4 3
5 class errorModel extends model { 4 class errorModel extends model {
6 constructor(ctx) { 5 constructor(ctx) {
@@ -12,7 +11,7 @@ class errorModel extends model { @@ -12,7 +11,7 @@ class errorModel extends model {
12 pageSize = pageSize || 10; 11 pageSize = pageSize || 10;
13 12
14 let recordsTotal = await this.mysql.query('SELECT COUNT(*) as count from error_report where app = ?', [app]).then(([r]) => r.count); 13 let recordsTotal = await this.mysql.query('SELECT COUNT(*) as count from error_report where app = ?', [app]).then(([r]) => r.count);
15 - let data = await this.mysql.query('SELECT id, app, type, preq_id, req_id, uid, udid, code, line, `column`, script, message, stack, create_time as time from error_report where app = ? order by create_time desc limit ?, ? ', [app, page, pageSize]).then(r => r.map(vars.handleItem)); 14 + let data = await this.mysql.query('SELECT id, app, type, preqid, reqid, uid, udid, code, line, `column`, script, message, stack, create_time as time from error_report where app = ? order by create_time desc limit ?, ? ', [app, page, pageSize]);
16 15
17 return { 16 return {
18 recordsTotal, 17 recordsTotal,
1 const model = require('../../../lib/model'); 1 const model = require('../../../lib/model');
2 const mysqlPromise = require('../../../lib/mysql-apm'); 2 const mysqlPromise = require('../../../lib/mysql-apm');
3 -const vars = require('./vars');  
4 3
5 class slowRouteModel extends model { 4 class slowRouteModel extends model {
6 constructor(ctx) { 5 constructor(ctx) {
@@ -12,9 +11,7 @@ class slowRouteModel extends model { @@ -12,9 +11,7 @@ class slowRouteModel extends model {
12 pageSize = pageSize || 10; 11 pageSize = pageSize || 10;
13 12
14 let recordsTotal = await this.mysql.query('SELECT COUNT(*) as count from slow_duration where app = ?', [app]).then(([r]) => r.count); 13 let recordsTotal = await this.mysql.query('SELECT COUNT(*) as count from slow_duration where app = ?', [app]).then(([r]) => r.count);
15 - let data = await this.mysql.query('SELECT id, app, `type`, preq_id, req_id, uid, udid, api, route, duration, create_time as time from slow_duration where app = ? ORDER BY create_time DESC LIMIT ?, ? ', [app, page, pageSize]).then(r => {  
16 - return r.map(vars.handleItem)  
17 - }); 14 + let data = await this.mysql.query('SELECT id, app, `type`, preqid, reqid, uid, udid, api, route, duration, create_time as time from slow_duration where app = ? ORDER BY duration DESC LIMIT ?, ? ', [app, page, pageSize]);
18 15
19 return { 16 return {
20 recordsTotal, 17 recordsTotal,
@@ -69,6 +69,81 @@ @@ -69,6 +69,81 @@
69 69
70 70
71 <script> 71 <script>
  72 +// var selectedServer, selectedApp;
  73 +// var data_end_point = '/profile/error.json';
  74 +// var dataTable = null;
  75 +//
  76 +// function ajaxUrl() {
  77 +// let url = `${data_end_point}?app=${selectedApp}&server=${selectedServer}`;
  78 +// return url
  79 +// }
  80 +//
  81 +// $(function() {
  82 +// init();
  83 +// initTable();
  84 +// initSelect();
  85 +// });
  86 +//
  87 +// function init() {
  88 +// selectedServer = 'aws';
  89 +// selectedApp = 'default';
  90 +// }
  91 +//
  92 +// function initTable() {
  93 +// dataTable = $("#table-servers").DataTable({
  94 +// pageLength: 20,
  95 +// serverSide: true,
  96 +// retrieve: true,
  97 +// searching: false,
  98 +// ajax: ajaxUrl(),
  99 +// dataSrc: 'data',
  100 +// pageLength: 25,
  101 +// columns: [
  102 +// {data: 'time'},
  103 +// {data: 'app'},
  104 +// {data: 'type'},
  105 +// {data: 'reqID'},
  106 +// {data: 'uid'},
  107 +// {data: 'udid'},
  108 +// {data: 'code', defaultContent: '无'},
  109 +// {data: 'message', defaultContent: '无'},
  110 +// {data: 'script', defaultContent: '无'},
  111 +// {data: 'line'},
  112 +// {data: 'column'},
  113 +// {data: 'stack', defaultContent: '无'}
  114 +// ],
  115 +// data: [{
  116 +// time: "",
  117 +// app: "",
  118 +// type: "",
  119 +// reqID: "",
  120 +// uid: "",
  121 +// udid: "",
  122 +// code: "",
  123 +// message: "",
  124 +// script: "",
  125 +// line: "",
  126 +// column: "",
  127 +// stack: ""
  128 +// }],
  129 +// });
  130 +// }
  131 +//
  132 +// function initSelect() {
  133 +// $('#selectedApp').change(function() {
  134 +// selectedApp = $('#selectedApp').val();
  135 +// });
  136 +//
  137 +// $('#search').on('click', () => {
  138 +// _handleChanged();
  139 +// })
  140 +// }
  141 +//
  142 +// function _handleChanged() {
  143 +// dataTable && dataTable.ajax.url(ajaxUrl()).load();
  144 +// }
  145 +
  146 +
72 var selectedServer, selectedApp; 147 var selectedServer, selectedApp;
73 var data_end_point = '/profile/error.json'; 148 var data_end_point = '/profile/error.json';
74 var dataTable = null; 149 var dataTable = null;
@@ -102,7 +177,7 @@ @@ -102,7 +177,7 @@
102 {data: 'time'}, 177 {data: 'time'},
103 {data: 'app'}, 178 {data: 'app'},
104 {data: 'type'}, 179 {data: 'type'},
105 - {data: 'reqID'}, 180 + {data: 'reqid'},
106 {data: 'uid'}, 181 {data: 'uid'},
107 {data: 'udid'}, 182 {data: 'udid'},
108 {data: 'code', defaultContent: '无'}, 183 {data: 'code', defaultContent: '无'},
@@ -116,7 +191,7 @@ @@ -116,7 +191,7 @@
116 time: "", 191 time: "",
117 app: "", 192 app: "",
118 type: "", 193 type: "",
119 - reqID: "", 194 + reqid: "",
120 uid: "", 195 uid: "",
121 udid: "", 196 udid: "",
122 code: "", 197 code: "",
@@ -137,7 +212,8 @@ @@ -137,7 +212,8 @@
137 }, 212 },
138 targets: 0 213 targets: 0
139 } 214 }
140 - ], 215 + ]
  216 +
141 }); 217 });
142 } 218 }
143 219
@@ -50,11 +50,11 @@ const defaults = { @@ -50,11 +50,11 @@ const defaults = {
50 database: 'yoho_seo' 50 database: 'yoho_seo'
51 }, 51 },
52 apmMysql: { 52 apmMysql: {
53 - host: 'localhost', 53 + host: '192.168.102.168',
54 user: 'root', 54 user: 'root',
55 password: 'root', 55 password: 'root',
56 port: '3306', 56 port: '3306',
57 - database: 'web-apm' 57 + database: 'webapm'
58 }, 58 },
59 domains: { 59 domains: {
60 // test3 60 // test3