...
|
...
|
@@ -79,7 +79,7 @@ function handleCount(rows) { |
|
|
}
|
|
|
|
|
|
const profile_service = {
|
|
|
async time(server, start, end, app, lastTime) {
|
|
|
async mean(server, start, end, app, lastTime) {
|
|
|
const model = profile_sql.duration()
|
|
|
.select('*')
|
|
|
.where(APP[app]);
|
...
|
...
|
@@ -123,6 +123,26 @@ const profile_service = { |
|
|
|
|
|
return {code: 200, data: rows}
|
|
|
},
|
|
|
async time(server, start, end, app, lastTime) {
|
|
|
const model = profile_sql.duration()
|
|
|
.select('*')
|
|
|
.where(APP[app]);
|
|
|
|
|
|
if (lastTime) {
|
|
|
model.where('time', '>=', SqlBuilder.raw(`now() - ${lastTime}`))
|
|
|
}
|
|
|
|
|
|
if (start && end) {
|
|
|
model.where('time', '>=', start)
|
|
|
.where('time', '<', end);
|
|
|
}
|
|
|
|
|
|
const rows = await exec(SERVER[server], model.toSql())
|
|
|
.then(result => _.get(result, 'results[0].series[0]', []))
|
|
|
.then(handleZip);
|
|
|
|
|
|
return {cde: 200, data: rows};
|
|
|
},
|
|
|
async error(server, start, end, app, lastTime) {
|
|
|
const model = profile_sql.error()
|
|
|
.select('*')
|
...
|
...
|
@@ -146,10 +166,10 @@ const profile_service = { |
|
|
};
|
|
|
|
|
|
const profile_controller = {
|
|
|
async time_report_index(ctx) {
|
|
|
await ctx.render('action/profile_time');
|
|
|
async mean_report_index(ctx) {
|
|
|
await ctx.render('action/profile_mean');
|
|
|
},
|
|
|
async time_report_json(ctx) {
|
|
|
async mean_report_json(ctx) {
|
|
|
const start = ctx.query.start;
|
|
|
const end = ctx.query.end;
|
|
|
const app = ctx.query.app;
|
...
|
...
|
@@ -172,6 +192,19 @@ const profile_controller = { |
|
|
const result = await profile_service.count(server, start, end, app, lastTime);
|
|
|
ctx.body = result;
|
|
|
},
|
|
|
async time_report_index(ctx) {
|
|
|
await ctx.render('action/profile_time');
|
|
|
},
|
|
|
async time_report_json(ctx) {
|
|
|
const start = ctx.query.start;
|
|
|
const end = ctx.query.end;
|
|
|
const app = ctx.query.app;
|
|
|
const server = ctx.query.server || 'aws';
|
|
|
const lastTime = ctx.query.lastTime;
|
|
|
|
|
|
const result = await profile_service.time(server, start, end, app, lastTime);
|
|
|
ctx.body = result;
|
|
|
},
|
|
|
async error_report_index(ctx) {
|
|
|
await ctx.render('action/profile_error');
|
|
|
},
|
...
|
...
|
@@ -188,12 +221,15 @@ const profile_controller = { |
|
|
|
|
|
};
|
|
|
|
|
|
r.get('/time', profile_controller.time_report_index);
|
|
|
r.get('/time.json', profile_controller.time_report_json);
|
|
|
r.get('/mean', profile_controller.mean_report_index);
|
|
|
r.get('/mean.json', profile_controller.mean_report_json);
|
|
|
|
|
|
r.get('/count', profile_controller.count_report_index);
|
|
|
r.get('/count.json', profile_controller.count_report_json);
|
|
|
|
|
|
r.get('/time', profile_controller.time_report_index);
|
|
|
r.get('/time.json', profile_controller.time_report_json);
|
|
|
|
|
|
r.get('/error', profile_controller.error_report_index);
|
|
|
r.get('/error.json', profile_controller.error_report_json);
|
|
|
|
...
|
...
|
|