Commit e32078bb authored by 智勇's avatar 智勇

用户行为增加分页

parent 56c0c17c
......@@ -283,7 +283,7 @@ exports.db_sync = async function () {
this.logger.info(
{
namespace: req.name_space,
active: "db_sync",
active: "sync_db",
microservice_name: req.sync_db_name,
user: `${this.user.name}`,
user_mail: `${this.user.mail}`,
......@@ -293,13 +293,6 @@ exports.db_sync = async function () {
"use_cache:": req.use_cache,
}
});
// " active:", "db_sync",
// "namespace:", req.name_space,
// "sync_db_name:", req.sync_db_name,
// "not_delete_business_data:", req.not_delete_business_data,
// "use_cache:", req.use_cache,
// " user:", this.user);
} catch (error) {
}
......@@ -364,12 +357,6 @@ exports.reset_binlog = async function () {
user: `${this.user.name}`,
user_mail: `${this.user.mail}`,
}
// "| active:", "reset_binlog",
// "| namespace:", req.name_space,
// "| microservice_name:", "",
// "| user:", `${this.user.name}`,
// "| user_email:", `${this.user.mail}`,
// "~"
);
} catch (error) {
console.log(error)
......
let readline = require('readline');
let fs = require('fs');
exports.get = async function () {
let rl = readline.createInterface({
input: fs.createReadStream('logs/access.log')
});
let log = '', logs = [], time, namespace, active
rl.on('line', (line) => {
log = log + line
logs = log.split('~')
// for (let _log of logs) {
// time = _log.substring(1, 24)
// console.log(11, _log)
// namespace = _log.substring(_log.indexOf("{"), _log.indexOf("}") + 1)
// _log = _log.substring(_log.indexOf("}") + 1)
// console.log(22, _log)
// active = _log.split(":")[1]
// console.log(active)
exports.get_log = async function () {
await this.bindDefault();
let item = await this.mongo("statisticslog").getLog({
namespace: this.request.body.query.namespace,
active: this.request.body.query.active,
microservice_name: this.request.body.query.microservice_name,
// create_time: {
// $gt: new Date(new Date().getTime() - 3 * 24 * 60 * 60 * 1000)
// }
this.body = {
code: "0000", data: logs
}
})
}, { create_time: -1 }, this.request.body.query.num, this.request.body.query.count);
this.body = item
return
}
exports.get_log = async function () {
exports.get_log_count = async function () {
await this.bindDefault();
let item = await this.mongo("statisticslog").getLog({
let item = await this.mongo("statisticslog").getLogCount({
namespace: this.request.body.query.namespace,
active: this.request.body.query.active,
microservice_name: this.request.body.query.microservice_name,
create_time: {
$gt: new Date(new Date().getTime() - 3 * 24 * 60 * 60 * 1000)
}
}, { create_time: -1 });
// let item = await this.mongo("statisticslog").getLog(this.request.body.query, { create_time: { $slice: [this.request.body.slice.num, this.request.body.slice.count] } }, { create_time: -1 });
});
this.body = item
return
}
\ No newline at end of file
......@@ -8,7 +8,19 @@ exports.schema = [{
}];
exports.methods = {
getLog: async function (query, sort) {
getLog: async function (query, sort, num, count) {
if (query.namespace || query.namespace === '') {
query.namespace = new RegExp(query.namespace);
}
if (query.active || query.active === '') {
query.active = new RegExp(query.active);
}
if (query.microservice_name || query.microservice_name === '') {
query.microservice_name = new RegExp(query.microservice_name);
}
return await this.model("statisticslog").find(query).sort(sort).skip(num * count).limit(count)
},
getLogCount: async function (query) {
if (query.namespace || query.namespace === '') {
query.namespace = new RegExp(query.namespace);
......@@ -19,6 +31,6 @@ exports.methods = {
if (query.microservice_name || query.microservice_name === '') {
query.microservice_name = new RegExp(query.microservice_name);
}
return await this.model("statisticslog").find(query).sort(sort)
return await this.model("statisticslog").find(query).count()
}
}
\ No newline at end of file
}
......@@ -28,7 +28,7 @@ var StatisticsSchema = new Schema({
});
// mongoose.connect('mongodb://192.168.28.179:27017/qaHome')
mongoose.connect('mongodb://172.30.220.22:27017/qaHome')
mongoose.connect('mongodb://172.30.220.22:27017/qaHome', { useMongoClient: true })
var StatisticsLogModel = mongoose.model('StatisticsLog', StatisticsSchema);
var logger = {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment