mirror of
https://github.com/goharbor/harbor.git
synced 2024-09-27 13:02:59 +02:00
fix accessory count issue (#16867)
The count api should ignore the pagination. Signed-off-by: Wang Yan <wangyan@vmware.com>
This commit is contained in:
parent
77e2b91e46
commit
b068515c53
@ -366,19 +366,22 @@ func (a *artifactAPI) ListAccessories(ctx context.Context, params operation.List
|
||||
query.Keywords["SubjectArtifactID"] = artifact.ID
|
||||
|
||||
// list accessories according to the query
|
||||
total, err := a.accMgr.Count(ctx, query)
|
||||
if err != nil {
|
||||
return a.SendError(ctx, err)
|
||||
}
|
||||
accs, err := a.accMgr.List(ctx, query)
|
||||
if err != nil {
|
||||
return a.SendError(ctx, err)
|
||||
}
|
||||
total := len(accs)
|
||||
|
||||
var res []*models.Accessory
|
||||
for _, acc := range accs {
|
||||
res = append(res, model.NewAccessory(acc.GetData()).ToSwagger())
|
||||
}
|
||||
return operation.NewListAccessoriesOK().
|
||||
WithXTotalCount(int64(total)).
|
||||
WithLink(a.Links(ctx, params.HTTPRequest.URL, int64(total), query.PageNumber, query.PageSize).String()).
|
||||
WithXTotalCount(total).
|
||||
WithLink(a.Links(ctx, params.HTTPRequest.URL, total, query.PageNumber, query.PageSize).String()).
|
||||
WithPayload(res)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user