Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
workbiu-admin
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Boards
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
gxx
workbiu-admin
Commits
8698e6c6
Commit
8698e6c6
authored
Nov 14, 2017
by
gxx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
完成新用户总数 、用户参与度 统计 缺少页面显示
parent
88bd208a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
141 additions
and
65 deletions
+141
-65
StatisticsServiceContract.php
app/Contracts/StatisticsServiceContract.php
+2
-0
StatisticsController.php
app/Http/Controllers/StatisticsController.php
+18
-1
StatisticsService.php
app/Services/StatisticsService.php
+119
-64
web.php
routes/web.php
+2
-0
No files found.
app/Contracts/StatisticsServiceContract.php
View file @
8698e6c6
...
...
@@ -20,6 +20,8 @@ interface StatisticsServiceContract
public
function
UserRetention
();
public
function
AverageUserOperation
();
public
function
PageRetentionTime
();
public
function
NewUser
();
public
function
UserEngagement
();
}
\ No newline at end of file
app/Http/Controllers/StatisticsController.php
View file @
8698e6c6
...
...
@@ -80,17 +80,34 @@ class StatisticsController extends Controller
}
// 平均操作
public
function
AverageUserOperation
()
{
$data
=
$this
->
mStatistics
->
AverageUserOperation
();
return
$data
;
}
// 页面停留时间
public
function
RetentionTime
()
{
$data
=
$this
->
mStatistics
->
PageRetentionTime
();
return
$data
;
}
// 新用户
public
function
NewUsers
()
{
$data
=
$this
->
mStatistics
->
NewUser
();
return
$data
;
}
// 用户参与度
public
function
UserEngagement
()
{
$data
=
$this
->
mStatistics
->
UserEngagement
();
return
$data
;
}
}
app/Services/StatisticsService.php
View file @
8698e6c6
...
...
@@ -202,10 +202,10 @@ class StatisticsService implements StatisticsServiceContract
$activeUsers
=
$this
->
ActiveUser
();
$outflowUsers
=
$this
->
OutflowUser
();
$userTotals
=
$this
->
UserTotal
();
$outflow
=
ceil
(
round
(
$outflowUsers
[
'流失用户'
]
/
$userTotals
[
'全部用户'
]
*
100
,
2
)
)
;
$dayActive
=
ceil
(
round
(
$activeUsers
[
'昨日活跃用户'
]
/
$userTotals
[
'全部用户'
]
*
100
,
2
)
)
;
$monthActive
=
ceil
(
round
(
$activeUsers
[
'上一个月活跃用户'
]
/
$userTotals
[
'全部用户'
]
*
100
,
2
)
)
;
$weekActive
=
ceil
(
round
(
$activeUsers
[
'上一周活跃用户'
]
/
$userTotals
[
'全部用户'
]
*
100
,
2
))
;
$outflow
=
ceil
(
$outflowUsers
[
'流失用户'
]
/
$userTotals
[
'全部用户'
]
*
100
,
2
)
;
$dayActive
=
ceil
(
$activeUsers
[
'昨日活跃用户'
]
/
$userTotals
[
'全部用户'
]
*
100
,
2
)
;
$monthActive
=
ceil
(
$activeUsers
[
'上一个月活跃用户'
]
/
$userTotals
[
'全部用户'
]
*
100
,
2
)
;
$weekActive
=
ceil
(
$activeUsers
[
'上一周活跃用户'
]
/
$userTotals
[
'全部用户'
]
*
100
,
2
)
;
$data
=
[
'昨日活跃占比'
=>
$dayActive
.
'%'
,
'上一个月活跃占比'
=>
$monthActive
.
'%'
,
'上一周活跃占比'
=>
$weekActive
.
'%'
,
'流失用户占比'
=>
$outflow
.
'%'
];
return
$data
;
}
...
...
@@ -271,22 +271,21 @@ class StatisticsService implements StatisticsServiceContract
}
// 平均团队
$averageGroup
=
ceil
(
round
((
$creatorGroupCount
+
$participateGroupCount
)
/
count
(
$users
)
*
100
,
2
)
)
.
'%'
;
$averageGroup
=
ceil
(
(
$creatorGroupCount
+
$participateGroupCount
)
/
count
(
$users
)
*
100
)
.
'%'
;
// 平均项目
$averageProject
=
ceil
(
round
((
$creatorProjectCount
+
$participateProjectCount
)
/
count
(
$users
)
*
100
,
2
)
)
.
'%'
;
$averageProject
=
ceil
(
(
$creatorProjectCount
+
$participateProjectCount
)
/
count
(
$users
)
*
100
)
.
'%'
;
// 平均任务
$averageTask
=
ceil
(
round
(
$creatorTaskCount
/
count
(
$users
)
*
100
,
2
)
)
.
'%'
;
$averageTask
=
ceil
(
$creatorTaskCount
/
count
(
$users
)
*
100
)
.
'%'
;
// 平均日程
$averageSchedule
=
ceil
(
round
(
$creatorTaskCount
/
count
(
$users
)
*
100
,
2
))
.
'%'
;
$averageSchedule
=
ceil
(
$creatorTaskCount
/
count
(
$users
)
*
100
)
.
'%'
;
$data
=
[
'团队'
=>
$averageGroup
,
'项目'
=>
$averageProject
,
'任务'
=>
$averageTask
,
'日程'
=>
$averageSchedule
];
return
$data
;
// dd($averageGroup,$averageProject,$averageTask,$averageSchedule);
}
...
...
@@ -304,51 +303,35 @@ class StatisticsService implements StatisticsServiceContract
foreach
(
$pageTime
as
$page
){
if
(
$page
->
id
==
1
){
$a
+=
$page
->
time
;
}
if
(
$page
->
id
==
2
){
}
if
(
$page
->
id
==
2
){
$b
+=
$page
->
time
;
}
if
(
$page
->
id
==
3
){
}
if
(
$page
->
id
==
3
){
$c
+=
$page
->
time
;
}
if
(
$page
->
id
==
4
){
}
if
(
$page
->
id
==
4
){
$d
+=
$page
->
time
;
}
if
(
$page
->
id
==
5
){
}
if
(
$page
->
id
==
5
){
$e
+=
$page
->
time
;
}
if
(
$page
->
id
==
6
){
}
if
(
$page
->
id
==
6
){
$f
+=
$page
->
time
;
}
if
(
$page
->
id
==
7
){
}
if
(
$page
->
id
==
7
){
$g
+=
$page
->
time
;
}
if
(
$page
->
id
==
8
){
}
if
(
$page
->
id
==
8
){
$h
+=
$page
->
time
;
}
if
(
$page
->
id
==
9
){
}
if
(
$page
->
id
==
9
){
$i
+=
$page
->
time
;
}
if
(
$page
->
id
==
10
){
}
if
(
$page
->
id
==
10
){
$j
+=
$page
->
time
;
}
if
(
$page
->
id
==
11
){
}
if
(
$page
->
id
==
11
){
$k
+=
$page
->
time
;
}
if
(
$page
->
id
==
12
){
}
if
(
$page
->
id
==
12
){
$l
+=
$page
->
time
;
}
if
(
$page
->
id
==
13
){
}
if
(
$page
->
id
==
13
){
$m
+=
$page
->
time
;
}
if
(
$page
->
id
==
14
){
}
if
(
$page
->
id
==
14
){
$n
+=
$page
->
time
;
}
if
(
$page
->
id
==
15
){
}
if
(
$page
->
id
==
15
){
$o
+=
$page
->
time
;
}
if
(
$page
->
id
==
16
){
}
if
(
$page
->
id
==
16
){
$p
+=
$page
->
time
;
}
...
...
@@ -356,37 +339,109 @@ class StatisticsService implements StatisticsServiceContract
}
}
// 获取全部用户
$users
=
UserInfo
::
all
()
->
count
();
$invitation
=
ceil
(
round
(
$a
/
$users
))
.
's'
;
$timeline
=
ceil
(
round
(
$b
/
$users
))
.
's'
;
$project
=
ceil
(
round
(
$c
/
$users
))
.
's'
;
$filemanage
=
ceil
(
round
(
$d
/
$users
))
.
's'
;
$mine
=
ceil
(
round
(
$e
/
$users
))
.
's'
;
$company
=
ceil
(
round
(
$f
/
$users
))
.
's'
;
$myteam
=
ceil
(
round
(
$g
/
$users
))
.
's'
;
$mission
=
ceil
(
round
(
$h
/
$users
))
.
's'
;
$project_item
=
ceil
(
round
(
$i
/
$users
))
.
's'
;
$login
=
ceil
(
round
(
$j
/
$users
))
.
's'
;
$register
=
ceil
(
round
(
$k
/
$users
))
.
's'
;
$discussion
=
ceil
(
round
(
$l
/
$users
))
.
's'
;
$mission_settings
=
ceil
(
round
(
$m
/
$users
))
.
's'
;
$search_team
=
ceil
(
round
(
$n
/
$users
))
.
's'
;
$bangding_phone
=
ceil
(
round
(
$o
/
$users
))
.
's'
;
$search_user
=
ceil
(
round
(
$p
/
$users
))
.
's'
;
// dd($invitation,$timeline,$project,$filemanage,$mine,$company,$myteam,$mission,$project_item,$login,$register,$discussion,$mission_settings,$search_team,$bangding_phone
// ,$search_user
// );
$data
=
[
$invitation
,
$timeline
,
$project
,
$filemanage
,
$mine
,
$company
,
$myteam
,
$mission
,
$project_item
,
$login
,
$register
,
$discussion
,
$mission_settings
,
$search_team
,
$bangding_phone
,
$search_user
];
$invitation
=
ceil
(
$a
/
$users
)
.
's'
;
$timeline
=
ceil
(
$b
/
$users
)
.
's'
;
$project
=
ceil
(
$c
/
$users
)
.
's'
;
$filemanage
=
ceil
(
$d
/
$users
)
.
's'
;
$mine
=
ceil
(
$e
/
$users
)
.
's'
;
$company
=
ceil
(
$f
/
$users
)
.
's'
;
$myteam
=
ceil
(
$g
/
$users
)
.
's'
;
$mission
=
ceil
(
$h
/
$users
)
.
's'
;
$project_item
=
ceil
(
$i
/
$users
)
.
's'
;
$login
=
ceil
(
$j
/
$users
)
.
's'
;
$register
=
ceil
(
$k
/
$users
)
.
's'
;
$discussion
=
ceil
(
$l
/
$users
)
.
's'
;
$mission_settings
=
ceil
(
$m
/
$users
)
.
's'
;
$search_team
=
ceil
(
$n
/
$users
)
.
's'
;
$bangding_phone
=
ceil
(
$o
/
$users
)
.
's'
;
$search_user
=
ceil
(
$p
/
$users
)
.
's'
;
$data
=
[
'invitation'
=>
$invitation
,
'timeline'
=>
$timeline
,
'project'
=>
$project
,
'filemanage'
=>
$filemanage
,
'mine'
=>
$mine
,
'company'
=>
$company
,
'myteam'
=>
$myteam
,
'mission'
=>
$mission
,
'project_item'
=>
$project_item
,
'login'
=>
$login
,
'register'
=>
$register
,
'discussion'
=>
$discussion
,
'mission_settings'
=>
$mission_settings
,
'search_team'
=>
$search_team
,
'bangding_phone'
=>
$bangding_phone
,
'search_user'
=>
$search_user
];
return
$data
;
}
}
// 新用户
public
function
NewUser
()
{
$time
=
Carbon
::
now
();
$data
=
$time
->
subWeek
();
$newUserCount
=
0
;
$pc
=
0
;
$android
=
0
;
$iPad
=
0
;
$users
=
UserInfo
::
where
(
'created_at'
,
'>'
,
$data
)
->
where
(
function
(
$query
){
$query
->
where
(
'created_at'
,
'<'
,
date
(
'Y-m-d H:i:s'
,
mktime
(
0
,
0
,
0
,
date
(
'm'
),
date
(
'd'
),
date
(
'Y'
))));
})
->
get
();
if
(
!
$users
->
isEmpty
()){
$newUserCount
=
count
(
$users
);
foreach
(
$users
as
$user
){
if
(
$user
[
'terminal'
]
==
'pc'
){
$pc
+=
1
;
}
if
(
$user
[
'terminal'
]
==
'android'
){
$android
+=
1
;
}
if
(
$user
[
'terminal'
]
==
'iPad'
){
$iPad
+=
1
;
}
};
}
$result
=
([
'newUserCount'
=>
$newUserCount
,
'pc'
=>
$pc
,
'android'
=>
$android
,
'iPad'
=>
$iPad
]);
return
$result
;
}
// 用户参与度
public
function
UserEngagement
()
{
$users
=
UserInfo
::
all
();
if
(
!
$users
->
isEmpty
()){
$group
=
0
;
$project
=
0
;
$task
=
0
;
$schedule
=
0
;
$board
=
0
;
foreach
(
$users
as
$user
){
if
(
$user
[
'user_engagement'
]
!=
null
){
$engagement
=
json_decode
(
$user
[
'user_engagement'
]);
foreach
(
$engagement
as
$val
){
if
(
$val
->
name
==
'group'
){
$group
+=
1
;
}
if
(
$val
->
name
==
'project'
){
$project
+=
1
;
}
if
(
$val
->
name
==
'task'
){
$task
+=
1
;
}
if
(
$val
->
name
==
'schedule'
){
$schedule
+=
1
;
}
if
(
$val
->
name
==
'board'
){
$board
+=
1
;
}
}
}
}
}
// 获取全部用户
$userCount
=
count
(
$users
);
$engagementGroup
=
ceil
(
$group
/
$userCount
*
100
)
.
'%'
;
$engagementProject
=
ceil
(
$project
/
$userCount
*
100
)
.
'%'
;
$engagementTask
=
ceil
(
$task
/
$userCount
*
100
)
.
'%'
;
$engagementSchedule
=
ceil
(
$schedule
/
$userCount
*
100
)
.
'%'
;
$engagementBoard
=
ceil
(
$board
/
$userCount
*
100
)
.
'%'
;
$data
=
[
'group'
=>
$engagementGroup
,
'project'
=>
$engagementProject
,
'task'
=>
$engagementTask
,
'schedule'
=>
$engagementSchedule
,
'board'
=>
$engagementBoard
];
return
$data
;
dd
(
$engagementGroup
,
$engagementProject
,
$engagementTask
,
$engagementSchedule
,
$engagementBoard
);
}
...
...
routes/web.php
View file @
8698e6c6
...
...
@@ -88,6 +88,8 @@ Route::group(['prefix'=> 'statistics'],function (){
Route
::
get
(
'user_retention'
,
'StatisticsController@UserRetention'
)
->
name
(
'statistics.UserRetention'
);
Route
::
get
(
'average_user_operation'
,
'StatisticsController@AverageUserOperation'
)
->
name
(
'statistics.AverageUserOperation'
);
Route
::
get
(
'retention_time'
,
'StatisticsController@RetentionTime'
)
->
name
(
'statistics.RetentionTime'
);
Route
::
get
(
'new_user'
,
'StatisticsController@NewUsers'
)
->
name
(
'statistics.NewUser'
);
Route
::
get
(
'user_engagement'
,
'StatisticsController@UserEngagement'
)
->
name
(
'statistics.UserEngagement'
);
});
...
...
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