Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
ygopro-arena-api
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
ygopro-arena-api
Commits
ffe402e9
Commit
ffe402e9
authored
Nov 01, 2017
by
ganjingcun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
统计数据
parent
7fa53182
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
56 additions
and
1 deletion
+56
-1
routes/api.js
routes/api.js
+56
-1
No files found.
routes/api.js
View file @
ffe402e9
...
...
@@ -689,29 +689,77 @@ router.get('/report', function (req, res) {
var
totalActive
=
results
.
totalActive
.
rows
[
0
].
count
;
var
dateHour
=
""
var
h
=
""
var
hourlyDataMap
=
{
athletic
:
{},
entertain
:
{}
}
var
hourlyAvgMapAthletic
=
{}
var
hourlyAvgMapEntertain
=
{}
var
totalAthletic
=
0
var
totalEntertain
=
0
var
hourlyAthletic
=
results
.
hourlyAthletic
.
rows
;
_
.
forEach
(
hourlyAthletic
,
function
(
row
)
{
totalAthletic
++
dateHour
=
moment
(
row
.
start_time
).
format
(
"
YYYY-MM-DD HH
"
)
h
=
moment
(
row
.
start_time
).
format
(
"
H
"
)
if
(
hourlyDataMap
[
'
athletic
'
][
dateHour
])
{
hourlyDataMap
[
'
athletic
'
][
dateHour
]
++
;
}
else
{
hourlyDataMap
[
'
athletic
'
][
dateHour
]
=
1
;
}
if
(
hourlyAvgMapAthletic
[
h
])
{
hourlyAvgMapAthletic
[
h
]
++
;
}
else
{
hourlyAvgMapAthletic
[
h
]
=
1
;
}
})
var
hourlyEntertain
=
results
.
hourlyEntertain
.
rows
;
_
.
forEach
(
hourlyEntertain
,
function
(
row
)
{
totalEntertain
++
dateHour
=
moment
(
row
.
start_time
).
format
(
"
YYYY-MM-DD HH
"
)
h
=
moment
(
row
.
start_time
).
format
(
"
H
"
)
if
(
hourlyDataMap
[
'
entertain
'
][
dateHour
])
{
hourlyDataMap
[
'
entertain
'
][
dateHour
]
++
;
}
else
{
hourlyDataMap
[
'
entertain
'
][
dateHour
]
=
1
;
}
if
(
hourlyAvgMapEntertain
[
h
])
{
hourlyAvgMapEntertain
[
h
]
++
;
}
else
{
hourlyAvgMapEntertain
[
h
]
=
1
;
}
})
var
totalDays
=
moment
(
to_date
).
diff
(
from_date
,
'
days
'
)
//饼图
var
legendDataAthletic
=
[];
var
seriesDataAthletic
=
[];
for
(
var
i
=
0
;
i
<
24
;
i
++
)
{
legendDataAthletic
.
push
(
i
);
seriesDataAthletic
.
push
({
name
:
i
,
avg
:
((
hourlyAvgMapAthletic
[
i
]
||
0
)
/
totalDays
).
toFixed
(
2
),
value
:
hourlyAvgMapAthletic
[
i
]
||
0
});
}
var
legendDataEntertain
=
[];
var
seriesDataEntertain
=
[];
for
(
var
i
=
0
;
i
<
24
;
i
++
)
{
legendDataEntertain
.
push
(
i
);
seriesDataEntertain
.
push
({
name
:
i
,
avg
:
((
hourlyAvgMapEntertain
[
i
]
||
0
)
/
totalDays
).
toFixed
(
2
),
value
:
hourlyAvgMapEntertain
[
i
]
||
0
});
}
res
.
json
({
entertain
:
{
total
:
entertainTotal
,
...
...
@@ -724,7 +772,14 @@ router.get('/report', function (req, res) {
users
:
athleticUsers
},
totalActive
:
totalActive
,
hourlyDataMap
:
hourlyDataMap
hourlyDataMap
:
hourlyDataMap
,
totalDays
:
totalDays
,
totalEntertain
:
totalEntertain
,
totalAthletic
:
totalAthletic
,
legendDataAthletic
:
legendDataAthletic
,
seriesDataAthletic
:
seriesDataAthletic
,
legendDataEntertain
:
legendDataEntertain
,
seriesDataEntertain
:
seriesDataEntertain
});
});
...
...
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