mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-14 14:25:36 +01:00
Merge pull request #482 from ywk253100/dev
add parameter 'num' to list jobs
This commit is contained in:
commit
d6ef229cbf
@ -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")
|
||||
|
Loading…
Reference in New Issue
Block a user