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
f57e7b8f
Commit
f57e7b8f
authored
Nov 14, 2019
by
zhengjinlei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
查询数据
parent
d646a98d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
13 deletions
+22
-13
tasksapi.py
src/inspect_report/api/tasksapi.py
+22
-13
No files found.
src/inspect_report/api/tasksapi.py
View file @
f57e7b8f
...
...
@@ -27,7 +27,7 @@ class TasksApi(viewsets.ViewSet):
:param req:
:return:
"""
tasks
=
Tasks
.
objects
.
all
()
.
values
(
'id'
,
'name'
)
tasks
=
Tasks
.
objects
.
all
()
.
order_by
(
'-createdAt'
)
.
values
(
'id'
,
'name'
)
# return render(req, 'inspect/index.html', {'tasks': tasks})
return
Response
({
'code'
:
0
,
'msg'
:
'success'
,
'data'
:
tasks
})
...
...
@@ -64,11 +64,14 @@ class TasksApi(viewsets.ViewSet):
task_id
=
req
.
data
.
get
(
'task'
,
''
)
agent_name
=
req
.
data
.
get
(
'agentName'
,
''
)
start_date
=
req
.
data
.
get
(
'start_date'
,
(
datetime
.
now
()
+
timedelta
(
days
=-
30
))
.
strftime
(
'
%
Y-
%
m-
%
d'
))
end_date
=
req
.
data
.
get
(
'end_date'
,
(
datetime
.
now
()
+
timedelta
(
days
=
1
))
.
strftime
(
'
%
Y-
%
m-
%
d'
))
task_condition
=
{
'createdAt__gte'
:
start_date
,
'createdAt__lt'
:
end_date
}
end_date
=
req
.
data
.
get
(
'end_date'
,
datetime
.
now
()
.
strftime
(
'
%
Y-
%
m-
%
d'
))
task_condition
=
{
'createdAt__gte'
:
start_date
,
'createdAt__lt'
:
end_date
+
' 23:59:59'
}
tasks
=
[]
if
task_id
:
task_condition
[
'pk'
]
=
task_id
tasks
=
Tasks
.
objects
.
filter
(
**
task_condition
)
tk
=
Tasks
.
objects
.
get
(
pk
=
task_id
)
tasks
.
append
(
tk
)
else
:
tasks
=
Tasks
.
objects
.
filter
(
**
task_condition
)
return_data
=
{}
for
t
in
tasks
:
session_collection
=
t
.
sessionCollectionId
...
...
@@ -102,11 +105,14 @@ class TasksApi(viewsets.ViewSet):
task_id
=
req
.
data
.
get
(
'task'
,
''
)
num
=
req
.
data
.
get
(
'num'
,
'10'
)
start_date
=
req
.
data
.
get
(
'start_date'
,
(
datetime
.
now
()
+
timedelta
(
days
=-
30
))
.
strftime
(
'
%
Y-
%
m-
%
d'
))
end_date
=
req
.
data
.
get
(
'end_date'
,
(
datetime
.
now
()
+
timedelta
(
days
=
1
))
.
strftime
(
'
%
Y-
%
m-
%
d'
))
task_condition
=
{
'createdAt__gte'
:
start_date
,
'createdAt__lt'
:
end_date
}
end_date
=
req
.
data
.
get
(
'end_date'
,
datetime
.
now
()
.
strftime
(
'
%
Y-
%
m-
%
d'
))
task_condition
=
{
'createdAt__gte'
:
start_date
,
'createdAt__lt'
:
end_date
+
' 23:59:59'
}
tasks
=
[]
if
task_id
:
task_condition
[
'pk'
]
=
task_id
tasks
=
Tasks
.
objects
.
filter
(
**
task_condition
)
tk
=
Tasks
.
objects
.
get
(
pk
=
task_id
)
tasks
.
append
(
tk
)
else
:
tasks
=
Tasks
.
objects
.
filter
(
**
task_condition
)
return_data
=
{}
for
t
in
tasks
:
session_collection
=
t
.
sessionCollectionId
...
...
@@ -138,11 +144,14 @@ class TasksApi(viewsets.ViewSet):
task_id
=
req
.
data
.
get
(
'task'
,
''
)
num
=
req
.
data
.
get
(
'num'
,
'10'
)
start_date
=
req
.
data
.
get
(
'start_date'
,
(
datetime
.
now
()
+
timedelta
(
days
=-
30
))
.
strftime
(
'
%
Y-
%
m-
%
d'
))
end_date
=
req
.
data
.
get
(
'end_date'
,
(
datetime
.
now
()
+
timedelta
(
days
=
1
))
.
strftime
(
'
%
Y-
%
m-
%
d'
))
task_condition
=
{
'createdAt__gte'
:
start_date
,
'createdAt__lt'
:
end_date
}
end_date
=
req
.
data
.
get
(
'end_date'
,
datetime
.
now
()
.
strftime
(
'
%
Y-
%
m-
%
d'
))
task_condition
=
{
'createdAt__gte'
:
start_date
,
'createdAt__lt'
:
end_date
+
' 23:59:59'
}
tasks
=
[]
if
task_id
:
task_condition
[
'pk'
]
=
task_id
tasks
=
Tasks
.
objects
.
filter
(
**
task_condition
)
tk
=
Tasks
.
objects
.
get
(
pk
=
task_id
)
tasks
.
append
(
tk
)
else
:
tasks
=
Tasks
.
objects
.
filter
(
**
task_condition
)
return_data
=
{}
for
t
in
tasks
:
session_collection
=
t
.
sessionCollectionId
...
...
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