Fix empties

This commit is contained in:
ferreo 2024-07-30 02:22:38 +01:00
parent f4487c0040
commit e3593d4321
2 changed files with 22 additions and 2 deletions

View File

@ -49,7 +49,17 @@ func Queue(c *fiber.Ctx) error {
return finalReturn[i].Source.Name < finalReturn[j].Source.Name
})
result := finalReturn[adjustedPageNum*pageSize : (adjustedPageNum+1)*pageSize]
var result []domain.BuildQueueItem
startIndex := adjustedPageNum * pageSize
endIndex := (adjustedPageNum + 1) * pageSize
if startIndex >= len(finalReturn) {
result = []domain.BuildQueueItem{}
} else {
if endIndex > len(finalReturn) {
endIndex = len(finalReturn)
}
result = finalReturn[startIndex:endIndex]
}
response := QueueResponse{
Total: len(finalReturn),

View File

@ -52,7 +52,17 @@ func Packages(c *fiber.Ctx) error {
return finalReturn[i].Name < finalReturn[j].Name
})
result := finalReturn[adjustedPageNum*pageSize : (adjustedPageNum+1)*pageSize]
var result []domain.SourcePackage
startIndex := adjustedPageNum * pageSize
endIndex := (adjustedPageNum + 1) * pageSize
if startIndex >= len(finalReturn) {
result = []domain.SourcePackage{}
} else {
if endIndex > len(finalReturn) {
endIndex = len(finalReturn)
}
result = finalReturn[startIndex:endIndex]
}
response := PackagesResponse{
Total: len(finalReturn),