return count of jobs which are failed when listing policies

This commit is contained in:
Wenkai Yin 2016-07-05 18:57:04 +08:00
parent e2afc3e51c
commit 6f7c2aa5a5
2 changed files with 12 additions and 9 deletions

View File

@ -150,10 +150,12 @@ func FilterRepPolicies(name string, projectID int64) ([]*models.RepPolicy, error
sql := `select rp.id, rp.project_id, p.name as project_name, rp.target_id, sql := `select rp.id, rp.project_id, p.name as project_name, rp.target_id,
rt.name as target_name, rp.name, rp.enabled, rp.description, rt.name as target_name, rp.name, rp.enabled, rp.description,
rp.cron_str, rp.start_time, rp.creation_time, rp.update_time rp.cron_str, rp.start_time, rp.creation_time, rp.update_time,
count(rj.status) as error_job_count
from replication_policy rp from replication_policy rp
join project p on rp.project_id=p.project_id left join project p on rp.project_id=p.project_id
join replication_target rt on rp.target_id=rt.id ` left join replication_target rt on rp.target_id=rt.id
left join replication_job rj on rp.id=rj.policy_id and rj.status="error" `
if len(name) != 0 && projectID != 0 { if len(name) != 0 && projectID != 0 {
sql += `where rp.name like ? and rp.project_id = ? ` sql += `where rp.name like ? and rp.project_id = ? `

View File

@ -62,6 +62,7 @@ type RepPolicy struct {
StartTime time.Time `orm:"column(start_time)" json:"start_time"` StartTime time.Time `orm:"column(start_time)" json:"start_time"`
CreationTime time.Time `orm:"column(creation_time);auto_now_add" json:"creation_time"` CreationTime time.Time `orm:"column(creation_time);auto_now_add" json:"creation_time"`
UpdateTime time.Time `orm:"column(update_time);auto_now" json:"update_time"` UpdateTime time.Time `orm:"column(update_time);auto_now" json:"update_time"`
ErrorJobCount int `json:"error_job_count"`
} }
// Valid ... // Valid ...