Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
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
7abc3100
Commit
7abc3100
authored
Dec 12, 2019
by
zhengjinlei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
违规项统计
parent
04441033
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
4 deletions
+7
-4
tasksapi.py
src/inspect_report/api/tasksapi.py
+7
-4
No files found.
src/inspect_report/api/tasksapi.py
View file @
7abc3100
...
...
@@ -93,7 +93,10 @@ class TasksApi(viewsets.ViewSet):
task_condition
[
'task'
]
=
task_id
if
agent_name
:
task_condition
[
'agentName'
]
=
agent_name
tasks
=
RulesStat
.
objects
.
filter
(
**
task_condition
)
.
values
(
'rule'
,
'sessionCollectionId'
,
'rule_num'
)
# tasks = RulesStat.objects.filter(**task_condition).values('rule', 'sessionCollectionId', 'rule_num')
tasks
=
RulesStat
.
objects
.
all
()
.
filter
(
**
task_condition
)
\
.
extra
(
select
=
{
'rule'
:
"rule"
,
'sessionCollectionId'
:
'sessionCollectionId'
})
\
.
values
(
'rule'
,
'sessionCollectionId'
)
.
annotate
(
rule_num
=
Count
(
'id'
))
.
order_by
(
'-rule_num'
)
for
t
in
tasks
:
name
=
t
[
'rule'
]
if
name
in
return_data
.
keys
():
...
...
@@ -106,7 +109,7 @@ class TasksApi(viewsets.ViewSet):
for
k
,
v
in
return_data
.
items
():
v
[
'rule'
]
=
k
data_sort
.
append
(
v
)
data_sort
=
sorted
(
data_sort
,
key
=
lambda
x
:
x
[
'count'
],
reverse
=
True
)
#
data_sort = sorted(data_sort, key=lambda x: x['count'], reverse=True)
return
Response
({
'code'
:
0
,
'msg'
:
'success'
,
'data'
:
data_sort
})
@
action
([
'post'
],
detail
=
False
)
...
...
@@ -563,7 +566,7 @@ class TasksApi(viewsets.ViewSet):
# tasks = RulesStat.objects.filter(**task_condition).values('rule', 'sessionCollectionId', 'rule_num')
tasks
=
RulesStat
.
objects
.
all
()
.
filter
(
**
task_condition
)
\
.
extra
(
select
=
{
'rule'
:
"rule"
,
'sessionCollectionId'
:
'sessionCollectionId'
})
\
.
values
(
'rule'
,
'sessionCollectionId'
)
.
annotate
(
rule_num
=
Count
(
'id'
))
.
order_by
(
'-rule_num'
)
.
values
(
'rule'
,
'sessionCollectionId'
)
.
annotate
(
rule_num
=
Count
(
'id'
))
.
order_by
(
'-rule_num'
)
for
t
in
tasks
:
name
=
t
[
'rule'
]
if
name
in
return_data
.
keys
():
...
...
@@ -578,7 +581,7 @@ class TasksApi(viewsets.ViewSet):
v
[
'ratio'
]
=
round
(
v
[
'count'
]
/
call_count
,
2
)
if
call_count
else
0
v
[
'call_count'
]
=
call_count
data_sort
.
append
(
v
)
data_sort
=
sorted
(
data_sort
,
key
=
lambda
x
:
x
[
'count'
],
reverse
=
True
)
#
data_sort = sorted(data_sort, key=lambda x: x['count'], reverse=True)
return
Response
({
'code'
:
0
,
'msg'
:
'success'
,
'data'
:
data_sort
})
@
action
([
'post'
],
detail
=
False
)
...
...
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