Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
inspect_report
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
zhengjinlei
inspect_report
Commits
7ab2f372
Commit
7ab2f372
authored
5 years ago
by
zhengjinlei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
报表提供下载功能
parent
8a1a71fa
master
No related merge requests found
Changes
5
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
332 additions
and
6 deletions
+332
-6
__init__.py
src/inspect_report/api/__init__.py
+1
-0
dataapi.py
src/inspect_report/api/dataapi.py
+317
-0
tasksapi.py
src/inspect_report/api/tasksapi.py
+9
-5
cron.py
src/inspect_report/cron.py
+4
-1
urls_api_v1.py
src/inspect_report/urls_api_v1.py
+1
-0
No files found.
src/inspect_report/api/__init__.py
View file @
7ab2f372
...
@@ -2,3 +2,4 @@
...
@@ -2,3 +2,4 @@
# from .user import UserApi
# from .user import UserApi
from
.toolapi
import
ToolsApi
from
.toolapi
import
ToolsApi
from
.tasksapi
import
TasksApi
from
.tasksapi
import
TasksApi
from
.dataapi
import
DataApi
This diff is collapsed.
Click to expand it.
src/inspect_report/api/dataapi.py
0 → 100644
View file @
7ab2f372
This diff is collapsed.
Click to expand it.
src/inspect_report/api/tasksapi.py
View file @
7ab2f372
...
@@ -199,11 +199,14 @@ class TasksApi(viewsets.ViewSet):
...
@@ -199,11 +199,14 @@ class TasksApi(viewsets.ViewSet):
if
agent_name
:
if
agent_name
:
task_condition
[
'agentName'
]
=
agent_name
task_condition
[
'agentName'
]
=
agent_name
if
sort
==
'des'
:
if
sort
==
'des'
:
seats
=
SeatStat
.
objects
.
filter
(
**
task_condition
)
.
values
(
'agentName'
,
'validate_session'
,
'total_session'
)
\
seats
=
SeatStat
.
objects
.
filter
(
**
task_condition
)
.
extra
(
select
=
{
'agentName'
:
'agentName'
})
\
.
order_by
(
'-validate_session'
)
.
values
(
'agentName'
)
.
annotate
(
remainTime
=
Sum
(
'remainTime'
),
validate_session
=
Sum
(
'validate_session'
),
total_session
=
Sum
(
'total_session'
))
.
order_by
(
'-validate_session'
)
else
:
else
:
seats
=
SeatStat
.
objects
.
filter
(
**
task_condition
)
.
values
(
'agentName'
,
'validate_session'
,
'total_session'
)
\
seats
=
SeatStat
.
objects
.
filter
(
**
task_condition
)
.
extra
(
select
=
{
'agentName'
:
'agentName'
})
\
.
order_by
(
'validate_session'
)
.
values
(
'agentName'
)
.
annotate
(
remainTime
=
Sum
(
'remainTime'
),
validate_session
=
Sum
(
'validate_session'
),
total_session
=
Sum
(
'total_session'
))
.
order_by
(
'validate_session'
)
paginator
=
Paginator
(
seats
,
page_size
)
paginator
=
Paginator
(
seats
,
page_size
)
total_count
=
paginator
.
count
total_count
=
paginator
.
count
try
:
try
:
...
@@ -215,7 +218,8 @@ class TasksApi(viewsets.ViewSet):
...
@@ -215,7 +218,8 @@ class TasksApi(viewsets.ViewSet):
return_data
=
[]
return_data
=
[]
for
s
in
seats
:
for
s
in
seats
:
detail
=
{
'agentName'
:
s
[
'agentName'
],
'validate_session'
:
s
[
'validate_session'
],
detail
=
{
'agentName'
:
s
[
'agentName'
],
'validate_session'
:
s
[
'validate_session'
],
'total_session'
:
s
[
'total_session'
],
'ratio'
:
round
(
s
[
'validate_session'
]
/
s
[
'total_session'
],
2
)}
'remainTime'
:
s
[
'remainTime'
],
'total_session'
:
s
[
'total_session'
],
'ratio'
:
round
(
s
[
'validate_session'
]
/
s
[
'total_session'
],
2
)}
return_data
.
append
(
detail
)
return_data
.
append
(
detail
)
if
sort
==
'asc'
:
if
sort
==
'asc'
:
data_sort
=
sorted
(
return_data
,
key
=
lambda
x
:
x
[
'ratio'
])
data_sort
=
sorted
(
return_data
,
key
=
lambda
x
:
x
[
'ratio'
])
...
...
This diff is collapsed.
Click to expand it.
src/inspect_report/cron.py
View file @
7ab2f372
...
@@ -78,7 +78,8 @@ def seat_stat(start_date=None, end_date=None):
...
@@ -78,7 +78,8 @@ def seat_stat(start_date=None, end_date=None):
table_name
=
TABLE_PRE
+
t
[
'sessionCollectionId'
]
table_name
=
TABLE_PRE
+
t
[
'sessionCollectionId'
]
tn
=
CheckSession
.
set_table
(
table_name
)
tn
=
CheckSession
.
set_table
(
table_name
)
session_condition
=
{
'taskId'
:
t
[
'id'
]}
session_condition
=
{
'taskId'
:
t
[
'id'
]}
checks
=
tn
.
objects
.
filter
(
**
session_condition
)
.
values
(
'id'
,
'agentName'
,
'taskId'
,
'violationRuleCount'
)
checks
=
tn
.
objects
.
filter
(
**
session_condition
)
.
values
(
'id'
,
'agentName'
,
'remainTime'
,
'taskId'
,
'violationRuleCount'
)
seat_dict
=
{}
seat_dict
=
{}
seat_list
=
[]
seat_list
=
[]
for
check
in
checks
:
for
check
in
checks
:
...
@@ -86,12 +87,14 @@ def seat_stat(start_date=None, end_date=None):
...
@@ -86,12 +87,14 @@ def seat_stat(start_date=None, end_date=None):
if
check
[
'agentName'
]
in
seat_dict
.
keys
():
if
check
[
'agentName'
]
in
seat_dict
.
keys
():
seat
=
seat_dict
.
get
(
check
[
'agentName'
])
seat
=
seat_dict
.
get
(
check
[
'agentName'
])
seat
[
'total_session'
]
+=
1
seat
[
'total_session'
]
+=
1
seat
[
'remainTime'
]
=
check
[
'remainTime'
]
seat
[
'validate_session'
]
+=
1
if
check
[
'violationRuleCount'
]
>
0
else
0
seat
[
'validate_session'
]
+=
1
if
check
[
'violationRuleCount'
]
>
0
else
0
else
:
else
:
seat_dict
[
check
[
'agentName'
]]
=
{
'create_date'
:
start_date
,
'agentName'
:
check
[
'agentName'
],
seat_dict
[
check
[
'agentName'
]]
=
{
'create_date'
:
start_date
,
'agentName'
:
check
[
'agentName'
],
'taskId'
:
check
[
'taskId'
],
'task'
:
t
[
'name'
]
.
split
(
'_'
)[
0
],
'taskId'
:
check
[
'taskId'
],
'task'
:
t
[
'name'
]
.
split
(
'_'
)[
0
],
'sessionCollectionId'
:
t
[
'sessionCollectionId'
],
'total_session'
:
1
}
'sessionCollectionId'
:
t
[
'sessionCollectionId'
],
'total_session'
:
1
}
seat_dict
[
check
[
'agentName'
]][
'validate_session'
]
=
1
if
check
[
'violationRuleCount'
]
>
0
else
0
seat_dict
[
check
[
'agentName'
]][
'validate_session'
]
=
1
if
check
[
'violationRuleCount'
]
>
0
else
0
seat_dict
[
check
[
'agentName'
]][
'remainTime'
]
=
check
[
'remainTime'
]
for
k
,
v
in
seat_dict
.
items
():
for
k
,
v
in
seat_dict
.
items
():
seat_obj
=
{
'agentName'
:
k
}
seat_obj
=
{
'agentName'
:
k
}
seat_obj
.
update
(
v
)
seat_obj
.
update
(
v
)
...
...
This diff is collapsed.
Click to expand it.
src/inspect_report/urls_api_v1.py
View file @
7ab2f372
...
@@ -22,6 +22,7 @@ from . import api
...
@@ -22,6 +22,7 @@ from . import api
router
=
routers
.
DefaultRouter
()
router
=
routers
.
DefaultRouter
()
router
.
register
(
r'tools'
,
api
.
ToolsApi
,
base_name
=
'tools'
)
router
.
register
(
r'tools'
,
api
.
ToolsApi
,
base_name
=
'tools'
)
router
.
register
(
r'tasks'
,
api
.
TasksApi
,
base_name
=
'tasks'
)
router
.
register
(
r'tasks'
,
api
.
TasksApi
,
base_name
=
'tasks'
)
router
.
register
(
r'data'
,
api
.
DataApi
,
base_name
=
'data'
)
# Wire up our API using automatic URL routing.
# Wire up our API using automatic URL routing.
# Additionally, we include login URLs for the browsable API.
# Additionally, we include login URLs for the browsable API.
...
...
This diff is collapsed.
Click to expand it.
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