slowRouteModel.js 846 Bytes
const model = require('../../../lib/model');
const mysqlPromise = require('../../../lib/mysql-apm');

class slowRouteModel extends model {
    constructor(ctx) {
        super(ctx);
        this.mysql = new mysqlPromise();
    }

    async getList(app, page, pageSize) {
        pageSize =  pageSize || 10;

        let recordsTotal = await this.mysql.query('SELECT COUNT(*) as count from slow_duration_new where app = ?', [app]).then(([r]) => r.count);
        let data = await this.mysql.query('SELECT id, app, `type`, preqid, reqid, uid, udid, api, route, duration, create_time as time from slow_duration_new where app = ? ORDER BY create_time DESC LIMIT ?, ? ', [app, page, pageSize]);

        return {
            recordsTotal,
            recordsFiltered: recordsTotal,
            data
        }
    }
}

module.exports = slowRouteModel;