Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pisns-forum-api
Project
Project
Details
Activity
Releases
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
scrmGroup
pisns-forum-api
Commits
6c823d77
Commit
6c823d77
authored
Apr 20, 2015
by
陈志良
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
首页 - 社区信息
parent
92ddf72f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
12 deletions
+47
-12
forumLog.js
app/controllers/admin/forumLog.js
+47
-12
No files found.
app/controllers/admin/forumLog.js
View file @
6c823d77
...
@@ -8,25 +8,60 @@ var express = require('express'),
...
@@ -8,25 +8,60 @@ var express = require('express'),
mongoose
=
require
(
'mongoose'
);
mongoose
=
require
(
'mongoose'
);
//模型
//模型
var
ForumPvLog
=
mongoose
.
model
(
'ForumPVLog'
),
var
ForumPvLog
=
mongoose
.
model
(
'ForumPVLog'
),
ForumUvLog
=
mongoose
.
model
(
'ForumUVLog'
);
ForumUvLog
=
mongoose
.
model
(
'ForumUVLog'
),
ForumThread
=
mongoose
.
model
(
'ForumThread'
);
module
.
exports
=
function
(
app
)
{
module
.
exports
=
function
(
app
)
{
app
.
use
(
'/admin/forum'
,
router
);
app
.
use
(
'/admin/forum'
,
router
);
};
};
var
dateFormat
=
function
(
date
){
return
moment
(
new
Date
(
date
)).
format
(
'YYYY-MM-DD'
);
};
//社区情况(首页)
//社区情况(首页)
router
.
post
(
'/statistic '
,
function
(
req
,
res
,
next
)
{
router
.
get
(
'/statistic'
,
function
(
req
,
res
,
next
)
{
then
(
function
(
cont
){
var
yesterday
=
moment
(
new
Date
().
getTime
()
-
24
*
3600
*
1000
).
format
(
'YYYY-MM-DD'
),
before_yesterday
=
moment
(
new
Date
().
getTime
()
-
2
*
24
*
3600
*
1000
).
format
(
'YYYY-MM-DD'
);
}).
then
(
function
(
cont
){
var
y_begin
=
yesterday
,
y_end
=
yesterday
+
' 23:59:59'
,
}).
then
(
function
(
cont
){
by_begin
=
before_yesterday
,
by_end
=
before_yesterday
+
' 23:59:59'
;
var
q
=
{
ent_code
:
req
.
session
.
user
.
ent_code
};
then
.
parallel
([
function
(
cont
){
//昨天访问用户
q
.
created
=
{
$gte
:
y_begin
,
$lte
:
y_end
};
ForumUvLog
.
count
(
q
,
cont
);
},
function
(
cont
){
//前天访问用户
q
.
created
=
{
$gte
:
by_begin
,
$lte
:
by_end
};
ForumUvLog
.
count
(
q
,
cont
);
},
function
(
cont
){
//昨天发帖数
q
.
created
=
{
$gte
:
y_begin
,
$lte
:
y_end
};
ForumThread
.
count
(
q
,
cont
);
},
function
(
cont
){
//前天发帖数
q
.
created
=
{
$gte
:
by_begin
,
$lte
:
by_end
};
ForumThread
.
count
(
q
,
cont
);
}
]).
then
(
function
(
cont
,
datas
){
var
y_user
=
datas
[
0
],
by_user
=
datas
[
1
],
y_thread
=
datas
[
2
],
by_thread
=
datas
[
3
];
var
user_rate
=
(
by_user
===
0
)?
y_user
:(
y_user
/
by_user
).
toFixed
(
4
)
-
1
,
thread_rate
=
(
by_thread
===
0
)?
y_thread
:(
y_thread
/
by_thread
).
toFixed
(
4
)
-
1
;
cont
(
null
,
y_user
,
user_rate
,
y_thread
,
thread_rate
);
}).
then
(
function
(
cont
,
y_user
,
user_rate
,
y_thread
,
thread_rate
){
res
.
json
({
result
:
true
,
data
:{
user
:
y_user
,
user_rate
:
Math
.
round
(
user_rate
>
1
?
100
:
user_rate
<
0
?
0
:
user_rate
*
100
),
thread
:
y_thread
,
thread_rate
:
Math
.
round
(
thread_rate
>
1
?
100
:
thread_rate
<
0
?
0
:
thread_rate
*
100
)
}})
}).
fail
(
function
(
cont
,
err
){
}).
fail
(
function
(
cont
,
err
){
console
.
error
(
err
);
res
.
json
({
result
:
false
,
err
:
err
});
});
});
});
});
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