Merge pull request #482 from ywk253100/dev

add parameter 'num' to list jobs
This commit is contained in:
Wenkai Yin 2016-07-06 15:11:22 +08:00 committed by GitHub
commit d6ef229cbf

View File

@ -61,6 +61,7 @@ func (ra *RepJobAPI) List() {
var policyID int64
var repository, status string
var startTime, endTime *time.Time
var num int
var err error
policyIDStr := ra.GetString("policy_id")
@ -71,6 +72,17 @@ func (ra *RepJobAPI) List() {
}
}
numStr := ra.GetString("num")
if len(numStr) != 0 {
num, err = strconv.Atoi(numStr)
if err != nil {
ra.CustomAbort(http.StatusBadRequest, fmt.Sprintf("invalid num: %s", numStr))
}
}
if num <= 0 {
num = 200
}
endTimeStr := ra.GetString("end_time")
if len(endTimeStr) != 0 {
i, err := strconv.ParseInt(endTimeStr, 10, 64)
@ -100,7 +112,7 @@ func (ra *RepJobAPI) List() {
repository = ra.GetString("repository")
status = ra.GetString("status")
jobs, err := dao.FilterRepJobs(policyID, repository, status, startTime, endTime, 1000)
jobs, err := dao.FilterRepJobs(policyID, repository, status, startTime, endTime, num)
if err != nil {
log.Errorf("failed to filter jobs according policy ID %d, repository %s, status %s: %v", policyID, repository, status, err)
ra.RenderError(http.StatusInternalServerError, "Failed to query job")