mirror of
https://github.com/goharbor/harbor.git
synced 2025-01-10 18:07:42 +01:00
add parameter 'num' to list jobs
This commit is contained in:
parent
86d643c93f
commit
37fc63aacc
@ -61,6 +61,7 @@ func (ra *RepJobAPI) List() {
|
|||||||
var policyID int64
|
var policyID int64
|
||||||
var repository, status string
|
var repository, status string
|
||||||
var startTime, endTime *time.Time
|
var startTime, endTime *time.Time
|
||||||
|
var num int
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
policyIDStr := ra.GetString("policy_id")
|
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")
|
endTimeStr := ra.GetString("end_time")
|
||||||
if len(endTimeStr) != 0 {
|
if len(endTimeStr) != 0 {
|
||||||
i, err := strconv.ParseInt(endTimeStr, 10, 64)
|
i, err := strconv.ParseInt(endTimeStr, 10, 64)
|
||||||
@ -100,7 +112,7 @@ func (ra *RepJobAPI) List() {
|
|||||||
repository = ra.GetString("repository")
|
repository = ra.GetString("repository")
|
||||||
status = ra.GetString("status")
|
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 {
|
if err != nil {
|
||||||
log.Errorf("failed to filter jobs according policy ID %d, repository %s, status %s: %v", policyID, repository, status, err)
|
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")
|
ra.RenderError(http.StatusInternalServerError, "Failed to query job")
|
||||||
|
Loading…
Reference in New Issue
Block a user