Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qaHome
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
QA
qaHome
Commits
e32078bb
Commit
e32078bb
authored
Jun 25, 2018
by
智勇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
用户行为增加分页
parent
56c0c17c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
48 deletions
+31
-48
server.js
app/qa-home/controller/dbconfig/server.js
+1
-14
server.js
app/qa-home/controller/log/server.js
+14
-30
statisticslog.js
app/qa-home/model/mongo/statisticslog.js
+15
-3
app.js
src/app.js
+1
-1
No files found.
app/qa-home/controller/dbconfig/server.js
View file @
e32078bb
...
...
@@ -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
)
...
...
app/qa-home/controller/log/server.js
View file @
e32078bb
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
"
).
getLog
Count
({
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
app/qa-home/model/mongo/statisticslog.js
View file @
e32078bb
...
...
@@ -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
}
src/app.js
View file @
e32078bb
...
...
@@ -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
=
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment