From aba4726be8143f55db23d8f09fc6a302efe6623b Mon Sep 17 00:00:00 2001 From: jerrylizilong Date: Wed, 27 Mar 2019 11:08:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=97=A0=E6=B3=95=E6=8C=89?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E3=80=81=E7=B1=BB=E5=9E=8B=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E7=94=A8=E4=BE=8B=E9=9B=86=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/db/test_suite_manage.py | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/app/db/test_suite_manage.py b/app/db/test_suite_manage.py index ba90238..9bf345f 100644 --- a/app/db/test_suite_manage.py +++ b/app/db/test_suite_manage.py @@ -45,24 +45,33 @@ class test_suite_manage: log.log().logger.info(result) return result - def show_test_suites(self,conditionList, valueList, fieldlist,rows): - fieldlist=[] - if len(fieldlist)==0: - fieldlist = ['id', 'name', 'status', 'run_type','description','batchId'] + def show_test_suites(self, conditionList, valueList, fieldlist, rows): + fieldlist = [] + if len(fieldlist) == 0: + fieldlist = ['id', 'name', 'status', 'run_type', 'description', 'batchId'] search_value = fieldlist[0] log.log().logger.info(fieldlist) - for i in range(1,len(fieldlist)): - search_value = search_value + ','+fieldlist[i] - condition = '' + for i in range(1, len(fieldlist)): + search_value = search_value + ',' + fieldlist[i] + condition = 'isDeleted = 0 ' for i in range(len(conditionList)): - if i == 0: - condition += str(conditionList[i]) +' like "%'+str(valueList[i])+'%"' - else: - condition += ' and '+str(conditionList[i]) +' like "%'+str(valueList[i])+'%"' + if len(valueList[i]): + if conditionList[i] == 'run_type': + if valueList[i] == 'Chrome': + valueList[i] = 2 + elif valueList[i] == 'Android': + valueList[i] = 0 + elif valueList[i] == 'iOS': + valueList[i] = 1 + if conditionList[i] in ('id', 'status', 'run_type'): + condition += ' and ' + str(conditionList[i]) + ' = "' + str(valueList[i]) + '"' + else: + condition += ' and ' + str(conditionList[i]) + ' like "%' + str(valueList[i]) + '%"' results = [] - sql = 'select ' + str(search_value) + ' from test_suite where ' + str(condition) + ' and isDeleted = 0 order by id desc limit '+ str(rows)+';' + sql = 'select ' + str(search_value) + ' from test_suite where ' + str( + condition) + ' order by id desc limit ' + str(rows) + ';' cases = useDB.useDB().search(sql) - log.log().logger.info('cases : %s '%cases) + log.log().logger.info('cases : %s ' % cases) for i in range(len(cases)): result = {} result['id'] = cases[i][0]