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
ac8fa273
Commit
ac8fa273
authored
Jan 16, 2020
by
zhengjinlei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
统计违规项
parent
4ea3c1df
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
3 deletions
+4
-3
tasksapi.py
src/inspect_report/api/tasksapi.py
+1
-1
cron.py
src/inspect_report/cron.py
+3
-2
No files found.
src/inspect_report/api/tasksapi.py
View file @
ac8fa273
...
...
@@ -565,7 +565,7 @@ class TasksApi(viewsets.ViewSet):
start_date
=
req
.
data
.
get
(
'start_date'
,
(
datetime
.
now
()
+
timedelta
(
days
=-
1
))
.
strftime
(
'
%
Y-
%
m-
%
d'
))
end_date
=
req
.
data
.
get
(
'end_date'
,
datetime
.
now
()
.
strftime
(
'
%
Y-
%
m-
%
d'
))
q_start_date
=
datetime
.
strptime
(
start_date
,
'
%
Y-
%
m-
%
d'
)
.
date
()
q_end_date
=
(
datetime
.
strptime
(
end_date
,
'
%
Y-
%
m-
%
d'
)
+
+
timedelta
(
days
=
1
))
.
date
()
q_end_date
=
(
datetime
.
strptime
(
end_date
,
'
%
Y-
%
m-
%
d'
)
+
timedelta
(
days
=
1
))
.
date
()
session_condition
=
{
'create_date__gte'
:
q_start_date
,
'create_date__lt'
:
q_end_date
}
if
agent_name
:
...
...
src/inspect_report/cron.py
View file @
ac8fa273
...
...
@@ -38,10 +38,10 @@ def rule_stat(start_date=None, end_date=None):
session_condition
=
{
'taskId'
:
t
[
'id'
],
'violationRuleCount__gt'
:
0
}
checks
=
tn
.
objects
.
filter
(
**
session_condition
)
.
values
(
'id'
,
'checkResult'
,
'agentName'
,
'customName'
,
'score'
,
'remainTime'
,
'taskId'
,
'sessionId'
)
rules_list
=
[]
for
check
in
checks
:
result
=
check
[
'checkResult'
]
if
result
:
rules_list
=
[]
data
=
json
.
loads
(
result
)
for
d
in
data
:
if
'isViolation'
in
d
.
keys
()
and
d
[
'isViolation'
]
and
'rule'
in
d
.
keys
()
and
'name'
in
d
[
'rule'
]
.
keys
():
...
...
@@ -54,7 +54,8 @@ def rule_stat(start_date=None, end_date=None):
'session_table_id'
:
check
[
'id'
]}
rules_list
.
append
(
RulesStat
(
**
rule_obj
))
stat_count
+=
1
RulesStat
.
objects
.
bulk_create
(
rules_list
)
logger
.
info
(
'rule stat num: [
%
s]'
,
stat_count
)
RulesStat
.
objects
.
bulk_create
(
rules_list
)
logger
.
info
(
'[rule_stat]rule stat num: [
%
s]'
,
stat_count
)
logger
.
info
(
'[rule_stat]rule stat end.'
)
...
...
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