def on_get(self, req, resp, plan_id):
if plan_id.isdigit():
where = 'WHERE `plan`.`id` = %s'
else:
where = 'WHERE `plan`.`name` = %s AND `plan_active`.`plan_id` IS NOT NULL'
query = single_plan_query + where
connection = db.engine.raw_connection()
cursor = connection.cursor(db.dict_cursor)
cursor.execute(query, plan_id)
plan = cursor.fetchone()
if plan:
step = 0
steps = []
cursor.execute(single_plan_query_steps, plan['id'])
for notification in cursor:
s = notification['step']
if s != step:
l = [notification]
steps.append(l)
step = s
else:
l.append(notification)
plan['steps'] = steps
if plan['tracking_template']:
plan['tracking_template'] = ujson.loads(plan['tracking_template'])
resp.body = ujson.dumps(plan)
connection.close()
else:
connection.close()
raise HTTPNotFound()
评论列表
文章目录