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
ff7bc26b
Commit
ff7bc26b
authored
Dec 13, 2019
by
zhengjinlei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
查询资源
parent
a88c4932
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
25 deletions
+10
-25
tasksapi.py
src/inspect_report/api/tasksapi.py
+10
-25
No files found.
src/inspect_report/api/tasksapi.py
View file @
ff7bc26b
...
...
@@ -42,33 +42,18 @@ class TasksApi(viewsets.ViewSet):
:return:
"""
task_id
=
req
.
GET
.
get
(
'task'
,
''
)
task_condition
=
{
'hasCheck'
:
1
}
session_condition
=
{}
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
()
session_condition
=
{
'create_date__gte'
:
q_start_date
,
'create_date__lt'
:
q_end_date
}
if
task_id
:
task_condition
[
'name__startswith'
]
=
task_id
tasks
=
Tasks
.
objects
.
filter
(
**
task_condition
)
.
values
(
'id'
,
'sessionCollectionId'
)
task_dict
=
{}
for
t
in
tasks
:
if
t
[
'sessionCollectionId'
]
in
task_dict
.
keys
():
task_dict
[
t
[
'sessionCollectionId'
]]
.
append
(
t
[
'id'
])
else
:
task_dict
[
t
[
'sessionCollectionId'
]]
=
[
t
[
'id'
],
]
session_condition
[
'task'
]
=
task_id
seats
=
SeatStat
.
objects
.
filter
(
**
session_condition
)
.
values
(
'agentName'
)
return_data
=
[]
for
k
,
v
in
task_dict
.
items
():
# session_collection = t['sessionCollectionId']
table_name
=
TABLE_PRE
+
k
tn
=
CheckSession
.
set_table
(
table_name
)
session_condition
[
'taskId__in'
]
=
v
agents
=
tn
.
objects
.
filter
(
**
session_condition
)
.
values
(
'agentName'
)
# .annotate(Count=Count('agentName')).values('agentName')
# if agents:
# return_data.append(agents)
for
agent
in
agents
:
if
agent
not
in
return_data
:
return_data
.
append
(
agent
)
# data_reduce = lambda x, y: x if y in x else x + [y]
# return_data = reduce(data_reduce, [[], ] + return_data)
for
agent
in
seats
:
if
agent
not
in
return_data
:
return_data
.
append
(
agent
)
return
Response
({
'code'
:
0
,
'msg'
:
'success'
,
'data'
:
return_data
})
@
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