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
863a5fd1
Commit
863a5fd1
authored
Nov 18, 2019
by
zhengjinlei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
获取坐席列表
parent
2b6cdac5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
6 deletions
+15
-6
tasksapi.py
src/inspect_report/api/tasksapi.py
+15
-6
No files found.
src/inspect_report/api/tasksapi.py
View file @
863a5fd1
# coding: utf-8
from
django.shortcuts
import
render
from
django.db.models
import
Count
from
rest_framework
import
viewsets
from
rest_framework.decorators
import
action
from
rest_framework.request
import
Request
...
...
@@ -11,6 +12,8 @@ from config.config import TABLE_PRE
from
django.views.decorators.clickjacking
import
xframe_options_exempt
from
inspect_report
import
permissions
import
logging
from
functools
import
reduce
logger
=
logging
.
getLogger
(
__name__
)
...
...
@@ -40,18 +43,24 @@ class TasksApi(viewsets.ViewSet):
"""
task_id
=
req
.
GET
.
get
(
'task'
,
''
)
task_condition
=
{}
session_condition
=
{}
if
task_id
:
task_condition
[
'pk'
]
=
task_id
tasks
=
Tasks
.
objects
.
filter
(
**
task_condition
)
session_condition
[
'taskId'
]
=
task_id
tasks
=
Tasks
.
objects
.
filter
(
**
task_condition
)
.
values
(
'sessionCollectionId'
)
.
annotate
(
Count
=
Count
(
'sessionCollectionId'
))
return_data
=
[]
for
t
in
tasks
:
session_collection
=
t
.
sessionCollectionId
session_collection
=
t
[
'sessionCollectionId'
]
table_name
=
TABLE_PRE
+
session_collection
tn
=
CheckSession
.
set_table
(
table_name
)
agents
=
tn
.
objects
.
filter
(
taskId
=
t
.
id
)
.
values
(
'agentName'
)
for
agent
in
agents
:
if
agent
not
in
return_data
:
return_data
.
append
(
agent
)
agents
=
tn
.
objects
.
filter
(
**
session_condition
)
.
values
(
'agentName'
)
.
annotate
(
Count
=
Count
(
'agentName'
))
.
values
(
'agentName'
)
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
)
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