Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
K
kouling-admin
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
刘松
kouling-admin
Commits
50c5f4dd
Commit
50c5f4dd
authored
Dec 06, 2017
by
刘松
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
f95f1dfb
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
45 additions
and
19 deletions
+45
-19
app.bundle.js
app/built/app.bundle.js
+0
-0
gather.jsx
app/jsx/statistics/gather.jsx
+25
-10
config.default.js
config/config.default.js
+2
-2
controller.js
lib/controller.js
+15
-3
tao.js
lib/tao.js
+1
-0
hash.js
utils/hash.js
+2
-4
No files found.
app/built/app.bundle.js
View file @
50c5f4dd
This source diff could not be displayed because it is too large. You can
view the blob
instead.
app/jsx/statistics/gather.jsx
View file @
50c5f4dd
...
...
@@ -14,7 +14,7 @@ class Gather extends React.Component{
constructor
(
props
){
super
(
props
);
this
.
range
=
[
moment
().
subtract
(
6
,
'days'
).
format
(
'YYYYMMDD'
),
moment
().
format
(
'YYYYMMDD'
)];
this
.
state
=
{
qdgathers
:[],
status
:
'pending'
,
pagination
:{
current
:
1
,
pageSize
:
10
,
total
:
100
},
username
:
'channel'
,
tody
:{
tkl_count
:
0
,
count
:
0
,
schedule_count
:
0
}
,
none_tkls
:[]};
this
.
state
=
{
qdgathers
:[],
status
:
'pending'
,
pagination
:{
current
:
1
,
pageSize
:
10
,
total
:
100
},
username
:
'channel'
,
tody
:{
tkl_count
:
0
,
count
:
0
,
schedule_count
:
0
}
,
none_tkls
:[]
,
list
:[]
};
}
componentDidMount
(){
let
data
=
{
start
:
moment
().
add
(
-
6
,
'days'
).
format
(
'YYYYMMDD'
),
end
:
moment
().
format
(
'YYYYMMDD'
)};
...
...
@@ -22,9 +22,8 @@ class Gather extends React.Component{
this
.
setState
({
username
:
document
.
cookie
.
match
(
'username=[a-zA-Z0-9]+'
)[
0
].
split
(
'='
)[
1
]});
}
api
(
'GET'
,
'gathers/qd'
).
then
((
res
)
=>
{
this
.
setState
({
qdgathers
:
res
.
result
,
status
:
'ready'
,
none_tkls
:
res
.
none_tkls
});
this
.
setState
({
qdgathers
:
res
.
result
,
status
:
'ready'
,
none_tkls
:
res
.
none_tkls
,
list
:
res
.
list
});
this
.
handle
(
res
.
list
,
res
.
tkl_count
)
console
.
dir
(
res
.
result
);
});
}
...
...
@@ -38,12 +37,10 @@ class Gather extends React.Component{
getQdGatherss
(
pagination
){
console
.
dir
(
pagination
);
this
.
setState
({
status
:
'pending'
})
api
(
'GET'
,
'gathers/qd?'
+
'skip='
+
(
pagination
.
current
-
1
)
+
'&limit='
+
pagination
.
pageSize
).
then
((
res
)
=>
{
this
.
setState
({
qdgathers
:
res
.
result
,
status
:
'ready'
,
pagination
:{
current
:
res
.
pagination
.
skip
,
pageSize
:
res
.
pagination
.
limit
,
total
:
res
.
pagination
.
total
},
none_tkls
:
res
.
none_tkls
});
this
.
setState
({
qdgathers
:
res
.
result
,
status
:
'ready'
,
pagination
:{
current
:
res
.
pagination
.
skip
,
pageSize
:
res
.
pagination
.
limit
,
total
:
res
.
pagination
.
total
},
none_tkls
:
res
.
none_tkls
,
list
:
res
.
list
});
this
.
handle
(
res
.
list
,
res
.
tkl_count
);
console
.
dir
(
res
.
result
);
});
}
...
...
@@ -116,19 +113,32 @@ class Gather extends React.Component{
});
}
var
none_tkls
=
this
.
state
.
none_tkls
;
var
list
=
this
.
state
.
list
;
var
sum
=
0
;
var
list_show
=
[];
var
sum_list_show
=
[];
for
(
var
i
in
none_tkls
){
sum
+=
none_tkls
[
i
][
'times'
];
let
qd
=
none_tkls
[
i
][
"qd"
];
if
(
qd
)
list_show
.
push
(<
p
>
{
qd
[
'user'
]
+
" "
+
none_tkls
[
i
][
'times'
]
}
</
p
>)
if
(
qd
)
list_show
.
push
(<
p
key=
{
qd
[
'user'
]
}
>
{
qd
[
'user'
]
+
" "
+
none_tkls
[
i
][
'times'
]
}
</
p
>)
}
var
map2qd
=
{};
for
(
var
k
in
list
){
if
(
list
[
k
]
&&
list
[
k
].
qd
&&
list
[
k
][
'qd'
][
'user'
])
map2qd
[
list
[
k
][
'qd'
][
'user'
]]
=
(
map2qd
[
list
[
k
][
'qd'
][
'user'
]]
?
(
map2qd
[
list
[
k
][
'qd'
][
'user'
]]
+
list
[
k
][
'sum'
])
:
list
[
k
][
'sum'
]);
}
for
(
var
j
in
map2qd
){
sum_list_show
.
push
(<
p
key=
{
j
}
>
{
j
+
" "
+
map2qd
[
j
]
}
</
p
>);
}
const
content
=
(
<
div
>
{
list_show
}
</
div
>
);
const
sum_content
=
(
<
div
>
{
sum_list_show
}
</
div
>);
return
(
<
div
>
...
...
@@ -136,8 +146,13 @@ class Gather extends React.Component{
<
Row
>
<
Col
span=
"6"
>
<
div
className
=
"
box
"
style=
{
{
marginLeft
:
'0px'
}
}
>
<
h3
>
请求数
</
h3
>
<
span
>
{
this
.
state
.
tody
.
count
}
</
span
>
<
h3
>
请求数
</
h3
>
{
this
.
state
.
username
!==
'admin'
?
<
span
>
{
this
.
state
.
tody
.
count
}
</
span
>
:
<
Popover
content=
{
sum_content
}
title=
"详情"
>
<
span
>
{
this
.
state
.
tody
.
count
}
</
span
>
</
Popover
>
}
</
div
>
</
Col
>
<
Col
span=
"6"
>
...
...
config/config.default.js
View file @
50c5f4dd
module
.
exports
=
{
host
:
'0.0.0.0'
,
port
:
process
.
env
.
PORT
?
process
.
env
.
PORT
:
9401
,
//
mongo:'mongodb://user:password@10.11.3.100:1302/taoarticle',
mongo
:
'mongodb://127.0.0.1:27017/taoarticle'
,
mongo
:
'mongodb://user:password@10.11.3.100:1302/taoarticle'
,
//
mongo:'mongodb://127.0.0.1:27017/taoarticle',
taobao
:
{
host
:
"http://gw.api.taobao.com/router/rest"
,
appKey
:
"24594025"
,
//"23580470",//"23390725",
...
...
lib/controller.js
View file @
50c5f4dd
...
...
@@ -70,17 +70,24 @@ exports.logs = async (req, res, next) => {
let
{
limit
=
100
,
skip
=
0
,
sort
=
{
'updatedAt'
:
-
1
}}
=
req
.
query
;
let
options
=
{
limit
:
parseInt
(
limit
),
skip
:
parseInt
(
skip
)
*
limit
,
sort
};
var
session_body
=
await
Session
.
findById
(
sess
);
var
logs
=
[];
var
total
=
0
;
if
(
session_body
){
var
user
=
session_body
.
toJSON
().
user
;
let
qs
=
{};
if
(
user
!=
'5a1e81f8c86fa7aa4b51b18b'
){
let
schedules
=
await
Schedule
.
find
({
qd
:
user
},
null
,{
limit
:
1000
});
schedules
=
schedules
.
map
(
x
=>
{
return
{
schedule
:
x
.
toJSON
().
_id
}});
console
.
dir
(
schedules
);
qs
=
{
$or
:
schedules
};
if
(
schedules
&&
schedules
.
length
)
{
total
=
await
Log
.
count
(
qs
,
null
);
logs
=
await
Log
.
find
(
qs
,
null
,
options
).
populate
({
path
:
"schedule"
,
select
:
"links qd"
,
populate
:{
path
:
'qd'
,
select
:
'user'
}});
}
}
else
{
logs
=
await
Log
.
find
(
qs
,
null
,
options
).
populate
({
path
:
"schedule"
,
select
:
"links qd"
,
populate
:{
path
:
'qd'
,
select
:
'user'
}});
total
=
await
Log
.
count
(
qs
,
null
);
}
var
logs
=
await
Log
.
find
(
qs
,
null
,
options
).
populate
({
path
:
"schedule"
,
select
:
"links qd"
,
populate
:{
path
:
'qd'
,
select
:
'user'
}});
let
total
=
await
Log
.
count
(
qs
,
null
);
logs
=
logs
.
map
(
x
=>
{
var
d
=
x
.
toJSON
();
d
[
'updatedAt'
]
=
dateFormat
(
d
[
'updatedAt'
]);
return
d
;});
res
.
send
({
status
:
'ok'
,
result
:
logs
,
pagination
:{
total
:
total
,
skip
:
skip
,
limit
:
limit
}});
}
...
...
@@ -142,6 +149,11 @@ exports.getQdGatherData = async (req, res, next) => {
}
}
]);
var
tasks
=
[];
list
.
forEach
(
async
(
item
,
i
)
=>
{
var
schedule
=
await
Schedule
.
findById
(
item
.
_id
).
populate
(
'qd'
,
'user'
);
list
[
i
][
'qd'
]
=
schedule
.
toJSON
().
qd
;
});
none_tkls
=
await
Nonetkl
.
find
({
date
:
match_qs
[
'date'
]}).
populate
(
'qd'
,
'user'
).
limit
(
1000
);
}
var
gatherDatas
=
await
GatherData
.
find
(
qs
,
null
,
options
).
populate
(
'qd'
,
'user'
);
...
...
lib/tao.js
View file @
50c5f4dd
...
...
@@ -42,6 +42,7 @@ exports.saveSchedule = async (data,cb) => {
}
exports
.
saveAgent
=
async
(
data
,
cb
)
=>
{
console
.
dir
(
data
);
try
{
var
agent
=
new
Agent
(
data
);
cb
(
null
,
await
agent
.
save
())
...
...
utils/hash.js
View file @
50c5f4dd
const
crypto
=
require
(
'crypto'
);
module
.
exports
=
(
str
,
algo
=
'sha256'
)
=>
{
module
.
exports
=
(
str
)
=>
{
if
(
!
str
)
return
''
;
const
hash
=
crypto
.
createHash
(
algo
);
hash
.
update
(
str
);
return
hash
.
digest
(
'hex'
);
return
crypto
.
createHash
(
'md5'
).
update
(
str
).
digest
(
'hex'
)
};
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