Commit f57e7b8f authored by zhengjinlei's avatar zhengjinlei

查询数据

parent d646a98d
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment