update zt_effort set product=concat(',', product, ',') where product not like ',%,';
CREATE OR REPLACE VIEW `ztv_projectstories` AS select `t1`.`project` AS `project`,count('*') AS `stories`,sum(if((`t2`.`status` = 'closed'),0,1)) AS `undone` from (`zt_projectstory` `t1` left join `zt_story` `t2` on((`t1`.`story` = `t2`.`id`))) where (`t2`.`deleted` = '0') group by `t1`.`project`;
CREATE OR REPLACE VIEW `ztv_projectsummary` AS select `zt_task`.`project` AS `project`, sum(if((`zt_task`.`parent` >= '0'),`zt_task`.`estimate`,0)) AS `estimate`, sum(if((`zt_task`.`parent` >= '0'),`zt_task`.`consumed`,0)) AS `consumed`, sum(if(((`zt_task`.`status` != 'cancel') and (`zt_task`.`status` != 'closed') and (`zt_task`.`parent` >= '0')),`zt_task`.`left`,0)) AS `left`, count(0) AS `number`, sum(if(((`zt_task`.`status` = 'wait') or (`zt_task`.`status` = 'doing')),1,0)) AS `undone`, sum((`zt_task`.`consumed` + if(((`zt_task`.`status` != 'cancel') and (`zt_task`.`status` != 'closed') and (`zt_task`.`parent` >= '0')),`zt_task`.`left`,0))) AS `totalReal` from `zt_task` where (`zt_task`.`deleted` = '0') group by `zt_task`.`project`;
