提交所有代码到 qiaoxinjiu 分支
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
# encoding: UTF-8
|
||||
from ..dao.planDao import PlanDao
|
||||
from ..model.planModel import PlanCase, TestPlan
|
||||
|
||||
|
||||
class PlanService(object):
|
||||
@@ -32,3 +33,22 @@ class PlanService(object):
|
||||
@staticmethod
|
||||
def plan_stats(session, plan_id):
|
||||
return PlanDao.plan_stats(session, plan_id)
|
||||
|
||||
@staticmethod
|
||||
def refresh_plan_status(session, plan_id):
|
||||
total = session.query(PlanCase).filter(PlanCase.plan_id == int(plan_id)).count()
|
||||
if total == 0:
|
||||
return
|
||||
unexecuted_count = session.query(PlanCase).filter(PlanCase.plan_id == int(plan_id), PlanCase.status == 0).count()
|
||||
failed_count = session.query(PlanCase).filter(PlanCase.plan_id == int(plan_id), PlanCase.status.in_([2, 3])).count()
|
||||
plan = PlanDao.get_by_id(session, TestPlan, plan_id)
|
||||
if not plan or plan.status == 3:
|
||||
return
|
||||
if unexecuted_count == 0:
|
||||
new_status = 4 if failed_count == 0 else 2
|
||||
elif unexecuted_count < total:
|
||||
new_status = 1
|
||||
else:
|
||||
new_status = plan.status
|
||||
if new_status != plan.status:
|
||||
PlanDao.update_by_id(session, TestPlan, plan_id, {'status': new_status})
|
||||
|
||||
Reference in New Issue
Block a user